yungbloodreborn Posted October 6, 2006 Share Posted October 6, 2006 I'm not sure if this is the best place to post this question, but since it's dealing directly with mysql, it seemed right.I have a snippet of code that says it's working, but it isn't.[code]$sql = mysql_query("UPDATE users SET email_address='$new_email_address', info='$info2' WHERE username='$username'"); if(!$sql){ $message = 'There has been an error updating your profile. Please contact the webmaster.'; include 'message.php';} else { $message = 'Your profile has been updated!'; include 'message.php';} [/code]It says it updates my profile, but it doesn't. But when I run the same line directly in phpmyadmin, it works fine. I'm using one file that has all the database info (server, login, pass, table) and it works fine for everything else. Quote Link to comment https://forums.phpfreaks.com/topic/23201-update-code-solved/ Share on other sites More sharing options...
fenway Posted October 6, 2006 Share Posted October 6, 2006 Check mysql_error() and see what you get. Quote Link to comment https://forums.phpfreaks.com/topic/23201-update-code-solved/#findComment-105255 Share on other sites More sharing options...
yungbloodreborn Posted October 7, 2006 Author Share Posted October 7, 2006 [code]$sql = mysql_query("UPDATE users SET email_address='$new_email_address', info='$info2' WHERE username='$username'") or die (mysql_error()); echo $sql;[/code]It prints a 1 for the $sql, and nothing for the mysql_error Quote Link to comment https://forums.phpfreaks.com/topic/23201-update-code-solved/#findComment-105314 Share on other sites More sharing options...
fenway Posted October 9, 2006 Share Posted October 9, 2006 Well, then your UPDATE is "successful"... that is, no errors were generated. Are you sure that the $username can be found? Quote Link to comment https://forums.phpfreaks.com/topic/23201-update-code-solved/#findComment-106082 Share on other sites More sharing options...
yungbloodreborn Posted October 9, 2006 Author Share Posted October 9, 2006 fenway, I found the problem. You pointed me in the right direction. You're right, it wasn't seeing $username because I had session_start() in the form that gets included, but not for the rest of the script. As soon as I put it at the top of this script, it worked perfectly. Thanks!! :) Quote Link to comment https://forums.phpfreaks.com/topic/23201-update-code-solved/#findComment-106439 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.