leeming Posted December 7, 2006 Share Posted December 7, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/29771-mysql-query-not-updating-because-of-null-fields/ Share on other sites More sharing options...
btherl Posted December 7, 2006 Share Posted December 7, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/29771-mysql-query-not-updating-because-of-null-fields/#findComment-136713 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.