Jump to content

mysql query not updating (because of null fields)


leeming

Recommended Posts

basically i have this query

[code]$sql = "UPDATE Accounts SET Account_Aim = '".htmlentities($_REQUEST['aim'], ENT_QUOTES)."', Account_Msn = '".htmlentities($_REQUEST['msn'], ENT_QUOTES)."', Account_Yahoo = '".htmlentities($_REQUEST['yahoo'], ENT_QUOTES)."', Account_Icq = '".htmlentities($_REQUEST['icq'], ENT_QUOTES)."', Account_Gender = '".htmlentities($_REQUEST['gender'], ENT_QUOTES)."', Account_Website = '".htmlentities($_REQUEST['userwebsite'], ENT_QUOTES)."', Account_Location = '".htmlentities($_REQUEST['location'], ENT_QUOTES)."', Account_Army_Name = '".htmlentities($_REQUEST['arname'], ENT_QUOTES)."', Account_Sig = '".htmlentities($_REQUEST['sig'], ENT_QUOTES)."', Account_Personal = '".htmlentities($_REQUEST['personal'], ENT_QUOTES)."' WHERE Account_ID = '".USERID."'";

    $query = mysql_query($sql, cdb(0))or die('wtf');//bavaderror($sql);[/code]

and i checked it after the query, for affected rows (which always returns true, even if no update was done)

basically i have found out that that the query is not updating because say if a user didnt put in an AIM  field, then it would be blank (this is a update profile page), but because its blank, this is leading to the query not updating... im not quite sure on this one.. but that's what's happening
Try printing out the query to see what is happening.  And the mysql error too, like this: [code=php:0] ... or die("Error in $sql: " . mysql_error());[/code]

Also, replace htmlentities() with mysql_real_escape_string().  That will do all the right escaping.  If you haven't done so already, you may need to urldecode() the variables before escaping them for mysql.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.