duanpen9294 2013-09-24 19:03 采纳率: 100%
浏览 274

奇怪的情况| 您的SQL语法有错误; 检查与MySQL服务器版本对应的手册[关闭]

I have a strange situation. I have this code:

$dispnam = strtoupper($display_name);
$data = mysql_connect("localhost", "user", "pass");
mysql_select_db("dbname");
$result = mysql_query("SELECT location FROM upload WHERE name = '".$dispnam."'")
or die(mysql_error());  
$check = mysql_num_rows($data);
$info = mysql_fetch_array($data);
$display_url = $info['location'];
echo $display_url;

which returns an error '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 'HIGHLIGHT'>BATMAN_SLAPPING_ROB' at line 1'

I have no idea where have I gone wrong. Your help will be greatly appreciated. Thanks iin advance!

  • 写回答

1条回答 默认 最新

  • douzhanbai9526 2013-09-24 19:06
    关注

    $dispnam seems to contain a single quote. You should be using a parametrized query instead of constructing your query from strings

    评论

报告相同问题?