samedi 30 janvier 2021

Error returned as Object of class mysqli_result could not be converted to string

I have function like below

function getUserBooking(){
        $uId = $_SESSION['userId'];
        $sql = "SELECT eventName,type,date,status FROM booking WHERE userId='$uId'";
        global $connection;
        $result = mysqli_query($connection,$sql);
        return $result; 
}

Then I call it as below and loop it as shown

$res = getUserBooking();
while($row = mysqli_fetch_assoc($res)){
    echo $row['eventName'];
    echo '<br>';
}

But it gives a error like below

Fatal error: Uncaught Error: Object of class mysqli_result could not be converted to string

What am I doing wrong here? Thank for your help !




Aucun commentaire:

Enregistrer un commentaire