mercredi 5 février 2020

PHP | Object of class mysqli_result could not be converted to string

I have a small problem with a form, my goal would be to check if a certain value exists within the database.

In this specific case, check if the user(pre_appuntamento_professionista_ID) is associated with that particular record id(ID_pre_appuntamento)

enter image description here

$id_richiesta_pre_appuntamento = $connessione->real_escape_string($_POST['id_richiesta_pre_appuntamento']);
$id_professionista_rich_precedentemnte_associata = $connessione->real_escape_string($_POST['id_professionista_pre_app']);

if I echo these two fields in the if loop I get perfectly the result 1 and 44

consider that the goal is that there is a job request where users must insert a token, but if the user with whom this request was already associated (44) applies for the latter (1) is recognized and prevented from insert the token

$check = mysqli_query($connessione,"
SELECT pre_appuntamento_professionista_ID
FROM pre_appuntamento
WHERE ID_pre_appuntamento = '$id_richiesta_pre_appuntamento'
AND pre_appuntamento_professionista_ID = '$id_professionista_rich_precedentemnte_associata'");
$result=mysqli_num_rows($check);

if($result==0)
{
    $messaggio = "yes" . $check;
}else{ $messaggio = "no" . $check;
}

but i have this error: Recoverable fatal error: Object of class mysqli_result could not be converted to string

how to fix this? Thanks!

1 commentaire:

  1. I don't know even I am getting the same here...I even tried mysqli_num_rows method. still it's not solved. Now I don't know what to do....hhhh!!! :(

    RépondreSupprimer