Jump to content

Registering On My Website: MySQL Syntax Error?


EPCtech

Recommended Posts

Hello,

My website, on the register page, says that my MySQL syntax to insert a member into the database is incorrect. Is there anything wrong with this? (P.S. - All variables exist)

 

mysql_query("INSERT INTO login(username, password, email)VALUES(".$username.",".$password.",".$email) or die(mysql_error());

 

I don't get it.

 

Best Regards,

En-Psyche Management

You want single quotes and no periods around your variables.

 

Posting the error would help catch it also.

 

mysql_query("INSERT INTO login (username, password, email)VALUES('$username', '$password', '$email'") or die(mysql_error());

Hello,

Now I have another problem. When I try making it so it adds the user group, it has the same error:

 

mysql_query("INSERT INTO login(username, password, email, group)VALUES('".$username."','".$password."','".$email."','".$group."')") or die(mysql_error());

 

Any help?

 

Best Regards,

En-Psyche Management

If you were to post the error messages you are getting, you would get a more direct and quicker solution because the error points to the place in the query where the problem is.

 

group is a reserved keyword. Either change the column name to something else or enclose it in back-ticks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.