RON_ron Posted November 11, 2010 Share Posted November 11, 2010 I'm trying to update a field in my MySQL but instead of updating this makes the field BLANK. my code: $SomeVar = $_POST['finco']; mysql_query("UPDATE c_applicants SET streetz='$cts' WHERE username = '".$SomeVar."'"); $result = mysql_query($query); Quote Link to comment https://forums.phpfreaks.com/topic/218373-coding-help/ Share on other sites More sharing options...
Adam Posted November 11, 2010 Share Posted November 11, 2010 Try: $sql = "UPDATE c_applicants SET streetz='" . $cts . "' WHERE username = '" . $SomeVar . "'"; $query = mysql_query($sql) or trigger_error('MySQL Error: ' . mysql_error(), E_USER_ERROR); Also remove the second mysql_query() call. If you don't get any errors, echo out $sql and make sure the values are valid. If they appear valid, it's still possible they're incorrect.. which you can verify with mysql_affected_rows, or by running the SQL in a MySQL administrator (i.e. PHPMyAdmin) to find the number of rows affected. Quote Link to comment https://forums.phpfreaks.com/topic/218373-coding-help/#findComment-1132978 Share on other sites More sharing options...
RON_ron Posted November 11, 2010 Author Share Posted November 11, 2010 Thanks Mr.Adam... When a field is updated it goes blank... ? What might be the issue here? Quote Link to comment https://forums.phpfreaks.com/topic/218373-coding-help/#findComment-1132984 Share on other sites More sharing options...
revraz Posted November 11, 2010 Share Posted November 11, 2010 You are doing it twice and the 2nd time it blanks it out. Quote Link to comment https://forums.phpfreaks.com/topic/218373-coding-help/#findComment-1132988 Share on other sites More sharing options...
RON_ron Posted November 11, 2010 Author Share Posted November 11, 2010 Hi revraz. But that's my code.. why did you say it's being updated twice? How can I correct this? Quote Link to comment https://forums.phpfreaks.com/topic/218373-coding-help/#findComment-1132990 Share on other sites More sharing options...
trq Posted November 11, 2010 Share Posted November 11, 2010 Where is $cts defined? Quote Link to comment https://forums.phpfreaks.com/topic/218373-coding-help/#findComment-1132993 Share on other sites More sharing options...
RON_ron Posted November 11, 2010 Author Share Posted November 11, 2010 that comes externally. Quote Link to comment https://forums.phpfreaks.com/topic/218373-coding-help/#findComment-1133012 Share on other sites More sharing options...
trq Posted November 11, 2010 Share Posted November 11, 2010 Well, it appears to be empty. Quote Link to comment https://forums.phpfreaks.com/topic/218373-coding-help/#findComment-1133037 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.