`
#天琪#
  • 浏览: 155855 次
  • 性别: Icon_minigender_2
  • 来自: 长沙
社区版块
存档分类
最新评论

问题答惑

    博客分类:
  • php
阅读更多
<?php
/*
$link = mysql_connect("127.0.0.1", "root", "123456");
mysql_select_db("book_sc", $link);
$result = mysql_query("SELECT * FROM books", $link);
$num_rows = mysql_num_rows($result);
echo "$num_rows 行\n";*/

$db = new mysqli('127.0.0.1', 'root', '123456', 'book_sc');
$result = $db->query("select * from books");
$row = $result->num_rows();
echo $row;
$result->close();
?>

$result->num_rows() 报错:Call to undefined method mysqli_result::num_rows()

解决方法:去掉$result->num_rows() 后面的括号
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics