Bobbycarver Posted March 17, 2013 Share Posted March 17, 2013 im trying to make a script where the user can update there details, (in this case the email) but when the script is running it comes up sucess to say its worked and updated. however when i open up my database in notepad or sql workbench the email has not changed its still the same. any ideas what it could be? or maybe im reading my database info wrong? CODE: <?php session_start(); $user_name = "root"; $password = ""; $database = "fixandrun"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); $currentemail = $_POST['currentemail']; $newemail = $_POST['newemail']; $confirmnew = $_POST['confirmemail']; $user = $_SESSION["username"]; if ($db_found) { $dbemail =mysql_query("SELECT email FROM staff WHERE username= '$user'"); //echo "$currentemail"; //echo "$newemail"; //echo "$confirmnew"; //echo "$dbemail"; if($currentemail == $dbemail || $newemail == $confirmnew) { $query = "UPDATE staff SET email = '$confirmnew' WHERE username = '$user'"; if(mysql_query($query)){ echo "updated";} else{ echo "fail";} } else { echo" some of your details are incorrect please try again. check that your current email is entered correctly and the new email matches."; } } else { print "Database NOT Found."; mysql_close($db_handle); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/275762-sql-database-not-updating/ Share on other sites More sharing options...
Solution Bobbycarver Posted March 17, 2013 Author Solution Share Posted March 17, 2013 solved. i wasnt reading the database correct. i created a new html page to print all my database and it was actually updating lol Quote Link to comment https://forums.phpfreaks.com/topic/275762-sql-database-not-updating/#findComment-1419111 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.