MYSQL语法错误1064

时间:2010-01-04 20:14:14

标签: php mysql mysql-error-1064

我无法弄清楚为什么从此查询中获取错误1064

//prep the data for database use
$manufacturer_id = $_GET['id'];
$manufacturer_display_name = mysql_prep($_POST['manufacturer_display_name']);
$manufacturer_name = mysql_prep($_POST['manufacturer_name']);


$query = "UPDATE IT_manufacturer SET
        manufacturer_name = '{$manufacturer_name}',
        manufacturer_display_name = '{$manufacturer_display_name}',
        WHERE manufacturer_id = {$manufacturer_id}
        ";

$result = mysql_query($query, $connection);
confirm_query ($result);

如果我回显变量$ manufacturer_name,$ manufacturer_display_name,$ manufacturer_id,它们都有值,但我收到此错误

无法执行查询您的SQL语法中有错误;查看与您的MySQL服务器版本对应的手册,以便在第4行错误编号1064的“WHERE manufacturer_id = 1”附近使用正确的语法

任何帮助

2 个答案:

答案 0 :(得分:6)

删除之前的逗号,应该是

    $query = "UPDATE IT_manufacturer SET manufacturer_name = '{$manufacturer_name}',
                 manufacturer_display_name = '{$manufacturer_display_name}' 
                 WHERE manufacturer_id = {$manufacturer_id} ";

逗号只分隔设置的不同变量,而不是其中的设置。

答案 1 :(得分:1)

在where:

之前删除逗号
'{$manufacturer_display_name}', WHERE manufacturer_id
                             ^^^