当用户点击ID为“保存”的提交按钮时,尝试更新数据库记录但是它不起作用,这是我对MYSQL更新查询的所有内容:
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”附近使用正确的语法,优先级='1',Call1 = '03 / 10/12',Call1Notes ='Test Call 1 Notes',Call2 ='at第2行
答案 0 :(得分:0)
好吧,假设这是所有代码,你有。假设您已连接到数据库,我没有看到您连接到数据库的位置。您没有执行查询。
在$ sql中进行sql查询后,执行此操作。
mysql_query($sql);
修改强>
您未在$Hometel
之后关闭引号。
答案 1 :(得分:0)
试试这个:
mysql_query($sql) or die(mysql_error());
它会给你错误
如果你无法修复它,请在此处发布。你会得到帮助。