开发者

MYSQL syntax error 1064 [closed]

This question is unlikely to help any future visitors; it is only relevant to a sm开发者_Python百科all geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 9 years ago.

I just cant figure out why am getting error 1064 from this query

//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);

If I echo the variables $manufacturer_name, $manufacturer_display_name, $manufacturer_id they all have values but am getting this error

could not excecute queryYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE manufacturer_id = 1' at line 4 error number 1064

Any help


Remove the comma before where, should be

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

commas only separate different variables being set, not the set from the where.


Remove the comma before the where:

'{$manufacturer_display_name}', WHERE manufacturer_id
                             ^^^
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜