码迷,mamicode.com
首页 > Web开发 > 详细

Fatal error: Call to a member function rowCount() on a non-object in /opt/lampp/htdocs/xampp/assets/update.php on line 6

时间:2018-01-16 17:57:27      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:select   直接   ocs   call   sql   nbsp   tle   desc   pos   

 $sql = "SELECT * from idea ORDER BY datetime DESC LIMIT 50;";
$result = $pdo->query($sql);

if($result->rowCount() > 0 && !empty($result)) // line 6
    {
        foreach ($result as $row) 
        {
        $id = $row[‘id‘];
        $title = $row[‘title‘];
        $idea = $row[‘idea‘];

        echo ‘<span class="idea" id="‘.$id.‘"><strong style="color: #0081C5">‘ . $title . "</strong> - " . $idea . ‘ <a class="delete" href="#">[Delete]</a></span>‘;
        }
    }
一般如果你的sql语句查询出现错误时,没有进行$result 的判断,直接使用$result -> rowCount()会出现这种错误。

Fatal error: Call to a member function rowCount() on a non-object in /opt/lampp/htdocs/xampp/assets/update.php on line 6

标签:select   直接   ocs   call   sql   nbsp   tle   desc   pos   

原文地址:https://www.cnblogs.com/ryanzheng/p/8296393.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!