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] Link to comment https://forums.phpfreaks.com/topic/76181-solved-reloading-a-page-in-if-statement-php/ 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 Link to comment https://forums.phpfreaks.com/topic/76181-solved-reloading-a-page-in-if-statement-php/#findComment-385556 Share on other sites More sharing options...
trq Posted November 6, 2007 Share Posted November 6, 2007 Post the function. Link to comment https://forums.phpfreaks.com/topic/76181-solved-reloading-a-page-in-if-statement-php/#findComment-385559 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; } Link to comment https://forums.phpfreaks.com/topic/76181-solved-reloading-a-page-in-if-statement-php/#findComment-385563 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 Link to comment https://forums.phpfreaks.com/topic/76181-solved-reloading-a-page-in-if-statement-php/#findComment-385569 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']; } } } } ?> Link to comment https://forums.phpfreaks.com/topic/76181-solved-reloading-a-page-in-if-statement-php/#findComment-385570 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.