phpmysqli

Fatal error: Call to undefined method mysqli::fetch_object()


Why am I getting the error:

Fatal error: Call to undefined method mysqli::fetch_object()

Heres my code:

$mysqli = new mysqli($db_data_hostname, $db_data_username, $db_data_password, $db_data_dbname);
    $query = "SELECT attName, attType, attOptions FROM form_constructor WHERE  device_name='$deviceType';";

    $result = $mysqli->query($query);

    while($row = $mysqli->fetch_object($result)){

        echo $row->attName;
        echo $row->attType;         
        echo $row->attOptions;

    }

Solution

  • You have to use the mysqli result:

    while($row = $result->fetch_object()){
    
            echo $row->attName;
            echo $row->attType;         
            echo $row->attOptions;
    
        }