嘗試當用戶點擊提交按鈕與「保存」的ID來更新數據庫中的記錄,但它不工作,這就是我對MYSQL的更新查詢:更新數據庫 - PHP
if ($_POST['SaveCall']) {
// set database server access variables:
$host = "localhost";
$user = "root";
$pass = "";
$db = "TILRenewals";
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to Choose database!");
$SPKCustNo = mysql_real_escape_string($_POST['SPKSelect']);
$FName = mysql_real_escape_string($_POST['FName']);
$SName = mysql_real_escape_string($_POST['SName']);
$PostCode = mysql_real_escape_string($_POST['PostCode']);
$Product = mysql_real_escape_string($_POST['Product']);
$PaymentMethod = mysql_real_escape_string($_POST['PaaymentMethod']);
$RenewalDate = mysql_real_escape_string($_POST['Renewa;Date']);
$HomeTel = mysql_real_escape_string($_POST['HomeTel']);
$WorkTel = mysql_real_escape_string($_POST['WorkTel']);
$Priority = mysql_real_escape_string($_POST['PriorityCheckBox']);
$Call1 = mysql_real_escape_string($_POST['Call1']);
$Call1Notes = mysql_real_escape_string($_POST['Call1Notes']);
$Call2 = mysql_real_escape_string($_POST['Call2']);
$Call2Notes = mysql_real_escape_string($_POST['Call2Notes']);
$Call3 = mysql_real_escape_string($_POST['Call3']);
$Call3Notes = mysql_real_escape_string($_POST['Call3Notes']);
$Call4 = mysql_real_escape_string($_POST['Call4']);
$Call4Notes = mysql_real_escape_string($_POST['Call4Notes']);
$Call5 = mysql_real_escape_string($_POST['Call5']);
$Call5Notes = mysql_real_escape_string($_POST['Call5Notes']);
$Outcome = mysql_real_escape_string($_POST['Outcome']);
$sql="UPDATE Data
SET ForeName = '$FName', Surname='$SName', PostCode='$PostCode', Product='$Product', PaymentMethod='$PaymentMethod',RenewalDate='$RenewalDate',HomeTel='$HomeTel,WorkTel='$WorkTel',Priority='$Priority',Call1='$Call1',Call1Notes='$Call1Notes',Call2='$Call2',Call2Notes='$Call2Notes',Call3='$Call3',Call3Notes='$Call3Notes',Call4='$Call4',Call4Notes='$Call4Notes',Call5='$Call5',Call5Notes='$Call5Notes',Outcome='$Outcome'
WHERE SPKCustNo='$SPKCustNo' ";
mysql_query($sql) or die(mysql_error()); ;
}
?>
燦有人幫忙嗎?謝謝!
*已經編輯了以上包括連接到數據庫,併發送查詢,現在我得到:你在你的SQL語法錯誤;請檢查對應於您的MySQL服務器版本的手冊,以在'01268510268',Priority ='1',Call1 = '03/10/12',Call1Notes ='Test Call 1 Notes',Call2 ='at第2行
你永遠不會發送查詢到服務器? – clentfort
http://www.catb.org/esr/faqs/smart-questions.html#beprecise – Quentin
這很好,你正確地轉義你的查詢參數,但如果你使用PDO或' mysqli'。 'mysql_query'接口已棄用,不應在新應用程序中使用。 – tadman