View Full Version : Cannot INSERT into table

04-03-2009, 11:53 PM
What is wrong here?

$con = mysql_connect("localhost","db_user","password");
if (!$con) { die('Could not connect: '); }
mysql_select_db("db_name", $con);

$sql = "INSERT INTO polls ( name, question, instructions)
VALUES ('$_POST[name]', '$_POST[question]', '$_POST[instructions]',)";

if (!mysql_query($sql))
die('could not update');
echo "1 record added";

It dies with 'could not update'

EDIT: I found the problem. It was a syntax error. I have highlited it

04-04-2009, 05:04 PM
if you have solved the problem please mark it as resolved

04-05-2009, 04:23 PM
also get in the habit of using mysql_error() with your queries and you would have gotten an actual error returned.