更新SQL不起作用。没有错误

时间:2014-09-20 05:37:14

标签: php mysql

这是我的更新代码。它显示“完成”但如果您检查数据库,则字段不会更新。

我的代码出了什么问题?

<?php include('include/dbconnect.php');

$page = $_POST['newpage'];
$title = $_POST['newtitle'];
$content = $_POST['newcontent'];
$track_no = $_POST['track_no'];
$done = "UPDATE contents SET page = '$page',title = '$title', content = '$content', modified = 'CURDATE()'WHERE track_no = '$track_no' ";     
$result = mysql_query($done) or die(mysql_error());
if (!$result)
{
    print "Something is wrong!";
}
else{
    print "Done!";
}

?>

2 个答案:

答案 0 :(得分:0)

只需从你的sql删除引用

$done = "UPDATE contents SET page = '$page',title = '$title', content = '$content', modified = CURDATE() WHERE track_no = '$track_no' ";

答案 1 :(得分:-1)

你做得对,但只是愚蠢的错误, YOU SHOULD MUST REMOVE THE SINGLE QUOTE IN CURDATE 就像,

$done = "UPDATE contents SET 
page = '$page',
title = '$title', 
content = '$content', 
modified = CURDATE() 
WHERE 
track_no = '$track_no' ";     

注意:任何日期或时间都没有在引用中提及。不是这个一个00-00-00