小编zla*_*012的帖子

mysql_query()返回true,但mysql_num_rows()和mysql_fetch_array()给出"没有有效的资源错误

这是有问题的代码:

来自index.php:

require_once('includes/DbConnector.php');

// Create an object (instance) of the DbConnector
$connector = new DbConnector();

// Execute the query to retrieve articles
$query1 = "SELECT id, title FROM articles ORDER BY id DESC LIMIT 0,5";
$result = $connector->query($query1);

echo "vardump1:";
var_dump($result);
echo "\n";

/*(!line 17!)*/ echo "Number of rows in the result of the query:".mysql_num_rows($result)."\n";
// Get an array containing the results.
// Loop for each item in that array


while ($row = $connector->fetchArray($result)){

echo '<p> <a href="viewArticle.php?id='.$row['id'].'">';
echo $row['title']; …
Run Code Online (Sandbox Code Playgroud)

php mysql

5
推荐指数
2
解决办法
3875
查看次数

标签 统计

mysql ×1

php ×1