Jump to content

Update code. Solved.


yungbloodreborn

Recommended Posts

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.
Link to comment
https://forums.phpfreaks.com/topic/23201-update-code-solved/
Share on other sites

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!! :)
Link to comment
https://forums.phpfreaks.com/topic/23201-update-code-solved/#findComment-106439
Share on other sites

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.