Page 1 of 1

MySQL query syntax with email addresses

Posted: Mon May 29, 2006 1:34 am
by punchthemonkey94
Hey guys. In my php code I want it to insert data into a database. When I try to do this, it returns 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 '@yourdomain.com,name)' at line 1
I think it might be confusing the @ character. Here is the original code:

Code: Select all

$query1 = "INSERT INTO Users(uname,pass,email,name) VALUES ($uname,$pass,$email,$name)";
mysql_query($query1)or die(mysql_error());
Thanks for any help.

Posted: Mon May 29, 2006 4:01 am
by timvw
String data should be quoted in SQL queries... eg:

Code: Select all

INSERT INTO foo (bar) VALUES ('$bar');