Page 1 of 1
variable dosen't get inserted
Posted: Wed Mar 02, 2005 12:46 pm
by Derek_24ca
Hello. Can someone take a look at this code for me?
Code: Select all
mysql_query("INSERT INTO table (email) values ($email)");
For some reason, $email dosen't get inserted into the mysql database. $email do contain a value from a form. Is this the right syntax?
Thanks.
Posted: Wed Mar 02, 2005 1:20 pm
by scorphus
Change the code to:
Code: Select all
$query = "INSERT INTO table (email) values ($email)";
mysql_query($query) or die('Error: ' . mysql_error() . '<br>Query: ' . $query);
and try to find out what is wrong by yourself.
-- Scorphus
Posted: Wed Mar 02, 2005 1:32 pm
by John Cartwright
Should always quote your variable names too..
Code: Select all
mysql_query("INSERT INTO `table` (`email`) values ('$email')") or die(mysql_erorr());
Posted: Wed Mar 02, 2005 1:40 pm
by scorphus
...that's what I wanted him to find out...