-2

我有这个问题,这是我的代码

        ?php
      $db_host = 'localhost';
      $db_user = 'root';
      $db_pwd = 'password';
      $database = 'nzpcgames';
      $table = 'gameinfo';


@ $dbcon = mysql_pconnect($db_host,$db_user,$db_pwd);
      if (!$dbcon)
      {
        die('Could not connect : ' . mysql_error());
        exit;
       }

mysql_select_db($database, $dbcon);

$query = "SELECT gameinfo.rank, gameinfo.game, gameinfo.platform, gameinfo.genre, gameinfo.publisher, gameinfo.developer, gameinfo.score*
FROM gameinfo
WHERE (((gameinfo.genre)='rpg'))";


$result = mysql_query("SELECT * FROM {$table}");
$num_rows = mysql_num_rows($result);
if ($num_rows == 0) {
    echo 'No results were found';
    exit;
}

   ?>

虽然每次我尝试执行它时,我都会收到标题错误。在我的教程 power point 上,它说要更改 $result,但没有说明要更改什么,谢谢您的帮助

4

1 回答 1

-2

可能是因为你没有把连接,

$result = mysql_query("SELECT * FROM {$table}",$dbcon);

或者你可以试试

SELECT COUNT(*) FROM $table_name

看看这个http://www.php.net/manual/en/function.mysql-num-rows.php

于 2012-04-21T00:41:16.150 回答