views:

184

answers:

2

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

+5  A: 

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.

Tim Hoolihan
works well thank you
Gatura
+1  A: 

Remove the comma before the where:

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