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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.