Search code examples
phpmysqlmysql-error-1064

Error is SQL syntax, unable to update mysql table


While updating a column 'client_name' in client table i got following 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 'WHERE client-id=2' at line 1

Here's the code:

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE client SET client_name=%s, WHERE client-id=%s",
                    GetSQLValueString($_POST['newcust'], "text"),
                    GetSQLValueString($_POST['select'], "int"));
        mysql_select_db($database_trackntrace, $trackntrace);
        $Result1 = mysql_query($updateSQL, $trackntrace) or die(mysql_error()); }

I am unable to rectify the error, need a little help.

Thanks


Solution

  • You have an additional , comma remove this

    UPDATE client SET client_name=%s, WHERE client-id=%s 
    

    to

    UPDATE client SET client_name=%s WHERE client-id=%s