PDA

Click to See Complete Forum and Search --> : [RESOLVED] php5 insert statement not working, whats the error mean


KiwiDexter
Feb 2nd, 2008, 08:34 PM
Am trying to get an insert statement working,


$sql = "insert into sbyd_member_group (mcid, name, desc, members) values ('$groupid', '$title', '$newdescription', 0)";
$result = mysql_query($sql ,$db);
die("$result = '" . $result . "'");


$result has null in it, what exactly does that mean? Clearly not working as am not seeing a new row being added :ehh:

penagate
Feb 2nd, 2008, 08:57 PM
It means the query failed for whatever reason.
Use the mysql_error function to see specifically why.

$result = mysql_query($sql, $db);

if (!is_resource($result))
{
die(mysql_error());
}


Replace die() with some other logic in a production environment, of course.

KiwiDexter
Feb 2nd, 2008, 09:19 PM
Thanks penagate :)

It didn't like the field name "desc" so changed to description and it's working like a brought thing :wave:

penagate
Feb 3rd, 2008, 01:00 AM
Yes, DESC is a keyword (descending order).