[英]PHP - SQL query Syntax Error
I'm having a hard time finding the error that exists in my script. 我很难找到脚本中存在的错误。 Can anyone help me spot it?
谁能帮我发现它?
case "process_movie_order":
// handle POST
if ($_POST) {
//Drop "order" column and Re-ADD it to reset ID #'s
$droppedresult = mysql_query("ALTER TABLE videos DROP COLUMN order");
$addedresult = mysql_query("ALTER TABLE videos ADD order int NOT NULL");
$totalMovies = count($_POST['movie']);
// use $i to increment the order number
$i=$totalMovies;
// loop through post array in the order it was submitted
foreach ($_POST['movie'] as $video_id) {
// update the row
$query = sprintf("UPDATE videos SET order='%s' WHERE video_id='%s'",
mysql_real_escape_string($i),
mysql_real_escape_string($video_id));
$result = mysql_query($query);
if(!$result) {
echo mysql_error();
echo 'MySQL query failed. Please report this error to the author of this script.<br />
<br />
<a href="'.$script_location.'?action=show_landing_page">Back</a><br />';
break;
}
// decrease order number to make the next movie lower
$i--;
}
}
You have an error in your SQL syntax; 您的SQL语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order='55' WHERE video_id='video55'' at line 1
检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在第1行的'order = '55'WHERE video_id ='video55'附近使用
Thanks! 谢谢!
order is a reserved keyword in MySQL. order是MySQL中的保留关键字。 You must specify the column name instead.
您必须改为指定列名称。 Put backticks around "order".
将反引号放在“命令”周围。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.