...

View Full Version : Cannot INSERT into table



RedMatrix
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

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

guelphdad
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum