scarhand Posted July 4, 2007 Share Posted July 4, 2007 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 More sharing options...
no_one Posted July 4, 2007 Share Posted July 4, 2007 " ... SET username='$newadminusername' WHERE username='$adminusername'" (I put single quotes around the $*adminusername vars) Might want to try printing mysql_error() Link to comment https://forums.phpfreaks.com/topic/58435-solved-table-not-updating-new-variable/#findComment-289755 Share on other sites More sharing options...
scarhand Posted July 4, 2007 Author Share Posted July 4, 2007 " ... 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 https://forums.phpfreaks.com/topic/58435-solved-table-not-updating-new-variable/#findComment-289767 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.