mysql_num_rows()需要参数1

时间:2014-02-18 07:31:51

标签: php mysql

$query = mysql_query($query);
$numrows = mysql_num_rows($query);
if ($numrows > 0){
  while ($row = mysql_fetch_assoc($quwey)){
    $id = $row['id'];
    $title = $row['title'];
    $description = $row['description'];
    $keywords = $row['keywords'];
    $link = $row['link'];

    echo "<h2><a href='$link'>$title</a></h2>$description<br /> <br />";            
  }     
} else {
  echo "No results found for \"<b>$keywords</b>\""; 
}

我可以找出它的错误。

2 个答案:

答案 0 :(得分:1)

   mysql_fetch_assoc($quwey)

您键入“$ query”而不是“$ query”

答案 1 :(得分:0)

        $result = mysql_query($query) or die(mysql_error());
        $numrows = mysql_num_rows($result);
        if ($numrows > 0) {

            while ($row = mysql_fetch_assoc($result)) {
                $id = $row['id'];
                $title = $row['title'];
                $description = $row['description'];
                $keywords = $row['keywords'];
                $link = $row['link'];

                echo "<h2><a href='$link'>$title</a></h2>$description<br /> <br />";
            }
        }