matt_jo84 Posted March 17, 2007 Share Posted March 17, 2007 I have been having problems with updating a table of mine for the past few days and cannot find a solution or reason why it is not working. What happens with the code below is a user logs in so an query is made to update their login status to 1 (0 = logged out, 1 = logged in). Then to make sure that the update to the database is made there is a check to see if it has been changed to 1 before the page is redirected to logged_IN.htm (the code below does find $login_num = 1). The problem is that in the table after the header function is executed. The value for login never changed to 1 in the table, it is always still 0. If I remove the header and have it not redirect to another page the login value in the table does change to 1. I have tried using 2 different servers also and still have no luck. Please help me out if you can, thanks. mysql_query("UPDATE " . $table . " SET login = '1' WHERE password = '$pass'"); $query_login = mysql_query("SELECT login FROM " . $table . " WHERE password = '$pass' "); $login_num = mysql_result($query_login, 0); if($login_num == '1') { header( "Location: http://www.website.com/logged_IN.htm" ); } Quote Link to comment https://forums.phpfreaks.com/topic/43167-problem-with-update-to-table/ Share on other sites More sharing options...
Barand Posted March 18, 2007 Share Posted March 18, 2007 Start by putting some debugging code in there <?php $sql = "UPDATE " . $table . " SET login = '1' WHERE password = '$pass'" ; mysql_query($sql) or die (mysql_error().'<p>$sql</p>'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/43167-problem-with-update-to-table/#findComment-209836 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.