Page 1 of 1

SQL query problem with $email variable

Posted: Tue Jul 02, 2002 6:02 am
by rsbeaulieu
$result = mysql_query("INSERT INTO contestlist SET Email=" . $Email);

Error performing query: You have an error in your SQL syntax near '@hotmail.com' at line 1
8O
This is by the way a shortened version, i did that so i could change things to see if they worked and well this is as close as i ever got.

Well obviusly SQL queries do not like the '@' symbol. :?
I hear admitting the problems we have is half the battle :)

Posted: Tue Jul 02, 2002 6:21 am
by twigletmac
Non numeric values should be enclosed in single quotes in your SQL query so:

Code: Select all

$sql = "INSERT INTO contestlist SET Email=".$Email;
should be

Code: Select all

$sql = "INSERT INTO contestlist SET Email='$Email'";
(There's no need to do concenation because the string is enclosed by double quotes.)

Mac

Posted: Tue Jul 02, 2002 6:36 am
by rsbeaulieu
Oh thank you, thank you thank you thank you thank you, ive rewritten that code so many ways i probably could of impressed u with my imagination.
It works and im again im thankful. :D