MySQL query syntax with email addresses

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
punchthemonkey94
Forum Newbie
Posts: 6
Joined: Mon May 29, 2006 1:22 am

MySQL query syntax with email addresses

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

String data should be quoted in SQL queries... eg:

Code: Select all

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