Syntax error MYSQL 1064

I just can't understand why I get error 1064 from this request

//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 repeat the variables $ manufacturer_name, $ manufacturer_display_name, $ manufacturer_id, they all matter, but I get this error

Failed to exclude request. You have an error in the SQL syntax; check the manual that matches your version of MySQL server for the correct syntax to use next to "WHERE manufacturer_id = 1" on line 4, error number 1064

Any help

+3
source share
2 answers

Remove the comma before where it 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, not a set of where.

+6

, :

'{$manufacturer_display_name}', WHERE manufacturer_id
                             ^^^
+1

Source: https://habr.com/ru/post/1727274/


All Articles