0

我收到下一段中显示的错误消息。下面粘贴的代码以前可以工作,但现在它给出了一个错误,甚至同一个文件也适用于其他页面等等......请帮帮我......

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在第 1 行的 '' 附近使用的正确语法:

<?php 

 // Connects to your Database 
 mysql_connect('localhost', 'root', '') or die(mysql_error()); 
 mysql_select_db('test') or die(mysql_error()); 

 //Adds to the click count for a particular link
 mysql_query("UPDATE items SET downloads = downloads + 1 WHERE id = $item_id")or die(mysql_error()); 

 //Retrieves information
 $data = mysql_query("SELECT * FROM items WHERE id = $item_id") or die(mysql_error()); 
 $info = mysql_fetch_array($data); 

header( "Location:" .$info['path'] );

?>
4

1 回答 1

0

好吧,我自己解决了。只有一点点改变,我得到了它的工作。我改变的是

WHERE id = ".$item_id."

<?php 

 // Connects to your Database 
 mysql_connect('localhost', 'root', '') or die(mysql_error()); 
 mysql_select_db('test') or die(mysql_error()); 

 //Adds to the click count for a particular link
 mysql_query("UPDATE items SET downloads = downloads + 1 WHERE id = ".$item_id."")or die(mysql_error()); 

 //Retrieves information
 $data = mysql_query("SELECT * FROM items WHERE id = ".$item_id."") or die(mysql_error()); 
 $info = mysql_fetch_array($data); 

header( "Location:" .$info['path'] );

?>
于 2013-09-18T17:39:49.687 回答