一个MySQL报错,谁知道哪错了

$update_sql = "UPDATE guestbook SET reply = '$reply', replytime = $replytime WHERE id = $_POST[id]";


报错提示:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

雷小天博客
浏览 3722回答 7
7回答

wcysky

SQL语句改下 $update_sql = "UPDATE guestbook SET reply = '".$reply."', replytime = $replytime WHERE id = $_POST[id]";单引号不解析php变量,被当做字符串了

mooc用户18273

$update_sql = "UPDATE guestbook SET reply = '{$reply}', replytime = {$replytime} WHERE id = {$_POST[id]}";试一下

多多尘

就是说你的数据库程序有点问题。需要你会过去数据库中修改,在第一行附近

青年賣魚丸

$update_sql = "UPDATE guestbook SET reply = '" .  mysql_real_escape_string($reply). "', replytime = '$replytime' WHERE id = {$_POST['id']}";

泥豆芽儿MT

 $update_sql = "UPDATE guestbook SET reply = '$reply', replytime = $replytime WHERE id = $_POST[id]";改成   $update_sql = "UPDATE guestbook SET  reply = “.$reply.", replytime = ".$replytime."WHERE id = ".$_POST[id]; 试试看

刘利利

SET reply = '$reply',这里是不行的,单引号不能解析变量,可以换成双引号

qq_言不由衷

我觉得是错在'$reply'   既然你是字符串拼接   就拼接起来啊    这是个字符串  在执行sql语句时这个变量也要带''单引号的
打开App,查看更多内容
随时随地看视频慕课网APP