RedMatrix
04-03-2009, 10: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
$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