MySQL syntax error: I'm stuck

$queryStatus = mysql_query("INSERT into `database`.`users` (`first`, `last`, `pass`, `user`, `id`, `email`, `active`) VALUES ('$first', '$last', '$password', '$user', NULL, '$email', '0'") or die("BAD QUERY: " . mysql_error());

Identifier field NULLbecause it is an automatic increment. But this throws a syntax error, and I really can't understand why. Please, help.

+3
source share
3 answers

Ignore the ID field, it will automatically add the value:

$queryStatus = mysql_query("INSERT into `database`.`users` (`first`, `last`, `pass`, `user`, `email`, `active`) VALUES ('$first', '$last', '$password', '$user', '$email', '0'") or die("BAD QUERY: " . mysql_error());

Also your request seems to be poorly formed (incorrectly puts a quotation mark at the end), I'm not sure about PHP, but this should work:

$queryStatus = mysql_query("INSERT into `database`.`users` (`first`, `last`, `pass`, `user`, `email`, `active`) VALUES ('$first', '$last', '$password', '$user', '$email', '0')");
+3
source

You do not close part of the request VALUES (). There must be a closed bracket at the end - do not confuse it with a closing bracket to call the function mysql_query.

+3
source

( ") , " ".

0

All Articles