thisisnuts123 Posted November 6, 2007 Share Posted November 6, 2007 hello guys if ( $turns == 0 ) { } if i wana reload a page if this statement if true, with out the user havign to click any thing how can this be done? i tried if ( $turns == 0 ) { header('Location: main.php'); die(); } it doesn;t seem to be working] Quote Link to comment Share on other sites More sharing options...
thisisnuts123 Posted November 6, 2007 Author Share Posted November 6, 2007 this code is insdie a funtion out side the funtion it works ok Quote Link to comment Share on other sites More sharing options...
trq Posted November 6, 2007 Share Posted November 6, 2007 Post the function. Quote Link to comment Share on other sites More sharing options...
thisisnuts123 Posted November 6, 2007 Author Share Posted November 6, 2007 function turns() { $query1 = "SELECT `turns` FROM user WHERE `username` = '$_SESSION[user]' "; $result1 = mysql_query($query1); $row1 = mysql_fetch_row($result1); $turn[0] = $row1[0]; $turns = $turn[0]; if ( $turns == 0 ) { header('Location: login.php'); die(); } elseif { .... etc etc.... } return $turns; } Quote Link to comment Share on other sites More sharing options...
thisisnuts123 Posted November 6, 2007 Author Share Posted November 6, 2007 function gets called by javascript.. using ajax Quote Link to comment Share on other sites More sharing options...
trq Posted November 6, 2007 Share Posted November 6, 2007 Theres allot of useless code in that function. Allong with absolutely no error handling. Try... <?php function turns() { $sql = "SELECT `turns` FROM user WHERE `username` = '{$_SESSION['user']}'"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)){ $row = mysql_fetch_assoc($result); if (!$row['turns']) { header('Location: login.php'); die(); } else { return $row['turns']; } } } } ?> Quote Link to comment 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.