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
https://forums.phpfreaks.com/topic/58435-solved-table-not-updating-new-variable/
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;
    }

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.