Jump to content

[SOLVED] table not updating new variable...


scarhand

Recommended Posts

    if ($_POST['adminusername'] != $adminusername)
    {
      $newadminusername = mysql_real_escape_string($_POST['adminusername']);
      mysql_query("UPDATE admin_user SET username=$newadminusername WHERE username=$adminusername");
      $status_msg .= "Your username has been changed to" . $newadminusername . ".<br />";
      $_SESSION['adminusername'] = $newadminusername;
    }

 

Whats wrong with this code? I'm stumped!

Link to comment
Share on other sites

" ... SET username='$newadminusername' WHERE username='$adminusername'"

 

(I put single quotes around the $*adminusername vars)

 

Might want to try printing mysql_error()

 

Thanks for the help, the quotes helped.

 

I'm using this and its working fine now:

 

    if ($_POST['adminusername'] != $adminusername)
    {
      $newadminusername = mysql_real_escape_string($_POST['adminusername']);
      mysql_query("UPDATE admin_user 
                   SET username='$newadminusername'
                   WHERE username='$adminusername'
                   ") or die(mysql_error());
      $update_msg .= "The admin username has been changed to " . $newadminusername . ".<br />";
      $_SESSION['adminusername'] = $newadminusername;
      $adminusername = $newadminusername;
    }

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.