0

当用户点击 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',Priority='1',Call1='03/10/12',Call1Notes='Test Call 1 Notes',Call2=' 附近使用正确的语法2号线

4

2 回答 2

0

好吧,假设这是所有的代码,你有。假设您确实连接到数据库,我看不到您连接到数据库的位置。您没有执行查询。

在 $sql 中获得 sql 查询后,执行此操作。 mysql_query($sql);

编辑

您没有在之后关闭报价$Hometel

于 2012-10-03T16:13:52.150 回答
0

试试这个:

mysql_query($sql) or die(mysql_error());

它会给你错误

如果您无法修复它,请在此处发布。你会得到帮助。

于 2012-10-03T16:21:28.083 回答