Hello I m having trouble with this script it gives this error message Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, object given in C:\xampp\htdocs\4.php on line 43 line 43 is if(mysqli_num_rows($stmt) !== 0){ Here is the script $tid = 1; /* create a prepared statement */ if ($stmt = mysqli_prepare($link, "SELECT users.username, topics.topic_body FROM `users` LEFT JOIN topics ON topics.topic_author = users.id WHERE topics.id=? order by edit_time ASC")) { /* bind parameters for markers */ mysqli_stmt_bind_param($stmt, "s", $tid); /* execute query */ mysqli_stmt_execute($stmt); /* bind result variables */ mysqli_stmt_bind_result($stmt, $name, $body); /* fetch value */ mysqli_stmt_fetch($stmt); if(mysqli_num_rows($stmt) !== 0){ while (mysqli_stmt_fetch($stmt)) { echo "username : <b>[" . $name . "]</b> replay : <b>[" . $body . "]</b><br> " ; } } else { echo "Not Found"; } /* close statement */ mysqli_stmt_close($stmt); } /* close connection */ mysqli_close($link); PHP: thanks
You're combining procedural and object oriented approaches, when you only want object oriented. Change if(mysqli_num_rows($stmt) !== 0){ to if(($stmt->num_rows()) !== 0){