PHP - While / Else error? [closed]
I have the following php code: <?php if (!isset($_REQUEST['search'])){ while(($write=mysql_fetch_array($gamesearched)) != null){ echo "Found!"; }else{ echo "No results"; } } ?> And it's giving me an error: Parse error: syntax error, unexpected 'else' (T_ELSE) in C:\php\www\Gameplay\backgame.php on line 41 jcsanyi In PHP, a while statement can't have an else clause. You need something external to the while that can tell you if it was executed at least once. How about something like this? $total = mysql_num_rows($gamesearched); if ($total > 0) { while (($write=mysql_fetch_array($gamesearched)) !