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