Search code examples
phpmysqlsqlreserved-words

You have an error in your SQL syntax - near 'left)


I'm a newbie in the php programming.

I would like to apply an insert query but I get this 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 'left) VALUES ('****df','****2135gh','***@yahoo.com' at line 2"}

$sql_insert_new_user = "insert into users (username,password,email,status,finance,province,city,address,tell,
mobile,admin_seen,type,left) VALUES ('$username','$password','$email',1,0,$town,$city,
'$address','$telephone','$mobile',0,'employe',0)";

            mysql_query($sql_insert_new_user);
            $error = mysql_error();

Solution

  • left is a reserved word and in the query you need escape with backtics

    `left`
    

    https://dev.mysql.com/doc/refman/5.5/en/reserved-words.html