Web Analytics Made Easy -
StatCounter Call to undefined method mysqli_result: - CodingForum

Announcement

Collapse
No announcement yet.

Call to undefined method mysqli_result:

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Call to undefined method mysqli_result:

    Hi,I am tring to fetch some dummy data from mysql and getting this error.How can I fix this and why I am getting this

    Code:
    $db=new mysqli("localhost","root","","app");
    $sql="select * from people";
    $results=$db->query($sql);
    
    if($results->num_rows()){
        while ($row=$results->fetch_object()){
            echo "{$row->first}";
        }
    }

  • #2
    Umm. That's not the complete error message, it would have been - Call to undefined method mysqli_result::num_rows().

    The reason for this error is because num_rows is a property, not a method, and doesn't use the () on the end of it. If you read the php.net documentation for any statement you are using or getting an error for, you can learn the proper usage.
    Finding out HOW to do something is called research, i.e. keep searching until you find the answer. After you attempt to do something and cannot solve a problem with it yourself, would be when you ask others for help.

    Comment

    Working...
    X