gmc1103 Posted April 30, 2015 Share Posted April 30, 2015 Hi I'm testing a query, this one SELECT COUNT(sala_ocupacao.`id_dia`) AS ocup FROM sala_ocupacao WHERE sala_ocupacao.`id_dia` = 1 AND sala_ocupacao.`id_sala`= 1 and the return is 17 When i use the prepared statement in php file $stmt = $mysqli->prepare("SELECT COUNT(sala_ocupacao.`id_dia`) FROM sala_ocupacao WHERE sala_ocupacao.`id_dia` = ? AND sala_ocupacao.`id_sala`= ? "); $stmt->bind_param('ss', $dia, $sala); $existe = $stmt->execute(); if ($existe != 0) { echo "Values found"; } The $existe variable gives me 1...and boolean...is normal? Regards Link to comment https://forums.phpfreaks.com/topic/295982-mysqli-prepared-statement/ Share on other sites More sharing options...
Barand Posted April 30, 2015 Share Posted April 30, 2015 A query can find no records without failing, it's a perfectly normal result. You need to check the number of rows in the results. Link to comment https://forums.phpfreaks.com/topic/295982-mysqli-prepared-statement/#findComment-1510428 Share on other sites More sharing options...
gmc1103 Posted April 30, 2015 Author Share Posted April 30, 2015 Hi Barand Thank you, the result inside the smtp query is 1 too, and should 17...i think Link to comment https://forums.phpfreaks.com/topic/295982-mysqli-prepared-statement/#findComment-1510441 Share on other sites More sharing options...
gizmola Posted April 30, 2015 Share Posted April 30, 2015 You did not show us any code that binds to the result or fetches. Where is that code? Link to comment https://forums.phpfreaks.com/topic/295982-mysqli-prepared-statement/#findComment-1510459 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.