Up to now I was checking num_rows >0 the following way:
$sql = "SELECT name FROM tbl_criteria WHERE ID =?";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)){
header("location: /XX");
}else{
mysqli_stmt_bind_param($stmt, "i", $cId);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
mysqli_fetch_all($result,MYSQLI_ASSOC);
if($result-> num_rows >0{
echo 'Appear if rows >0';
foreach($result as $row){
echo 'Appear for each result';
}
}
}
So suddenly this is not working anymore. I always get 0 results. I have read that it is important to call mysqli_stmt_store_result()
before accessing num_rows otherwise it would usually return 0. I thought that I'm storing the results with $result = mysqli_stmt_get_result($stmt);
or am I wrong?
I am hosting my website on a webserver so it could be because of an update as well. A couple of days ago it was working fine.