PHP MySQL可能是语法错误

时间:2014-02-13 17:38:08

标签: php mysql syntax

我不知道为什么,但我在这一行收到错误:$row = mysql_fetch_array($run_games)){ 这是代码:

<div class='topnav'> <!--Start of the Top Navigation-->
<?php
include("includes/connect.php");

$select_games = "SELECT * FROM games";

$run_games = mysql_query($select_games);

$row = mysql_fetch_array($run_games)){

$game_category = $row['game_category'];

?>

<!--some links here with the variable of "game_category"-->
<?php } ?>
</div> <!--End of the Top Navigation-->

请帮帮我:(

4 个答案:

答案 0 :(得分:0)

应该是......

while($row = mysql_fetch_array($run_games))
{
echo $game_category = $row['game_category'];
}

您需要遍历结果集!

答案 1 :(得分:0)

使用 while 循环遍历结果集。

$row = mysql_fetch_array($run_games)){

应该是

while($row = mysql_fetch_array($run_games)) {
   // do stuff  ...
}

答案 2 :(得分:0)

这可能是剪切和粘贴错误。缺少while循环的第一部分:

$row = mysql_fetch_array($run_games)){

应该是

while ($row = mysql_fetch_array($run_games)){

答案 3 :(得分:0)

不推荐使用这些功能,因此请使用最新功能

$row = mysql_fetch_array($run_games));//if only one row
//other wise should use while
while($row = mysql_fetch_array($run_games))
{
}