mysqli : mysqli_result could not be converted to string

前端 未结 2 1545
無奈伤痛
無奈伤痛 2020-12-12 06:01

I know there have been asked lots of similair questions like this one, but I just can\'t translate it to my problem so thats why I ask again. The code used to work fine but

相关标签:
2条回答
  • 2020-12-12 06:21

    That is because mysqli_result is a result set. I don't know what you would expect to gain from echoing it, just as you wouldn't get anything meaningful from echoing the result set of a mysql_query query which uses a SELECT.

    You need to use the various class methods to access data in the result set.

    http://php.net/manual/en/class.mysqli-result.php

    0 讨论(0)
  • 2020-12-12 06:30
    $num=$result->num_rows;
    
    echo "<b><center>Database Output</center></b><br><br>";
    
    while ($row = $result->fetch_assoc()) {  
    
       echo "<u>".$row['id']."</u><b>".$row['first']."</b>"; //etc...
     }
    

    is much easier.

    0 讨论(0)
提交回复
热议问题