How to fix Object of class mysqli_result could not be converted to string with PHP?

Spread the love

Sometimes, we want to fix Object of class mysqli_result could not be converted to string with PHP.

In this article, we’ll look at how to fix Object of class mysqli_result could not be converted to string with PHP.

How to fix Object of class mysqli_result could not be converted to string with PHP?

To fix Object of class mysqli_result could not be converted to string with PHP, we need to add a loop to loop through the records.

For instance, we write

while ($row = $result->fetch_assoc()) {
    echo $row["classtype"] . "<br>";
}

to get the records with fetch_assoc.

Then we get the record being looped through from $row.

Conclusion

To fix Object of class mysqli_result could not be converted to string with PHP, we need to add a loop to loop through the records.

Leave a Reply

Your email address will not be published.