php - Trying to get property of non-object -
i want if there no authors/users found exit given message below. keep striking trying property of non-object on $author_found_count. why this? thanks
$find_author = "select user reviews review_id=$review_id;"; $search_author = mysqli_query($con,$find_author); $found_author = mysqli_fetch_array($search_author); $author_found_count = $found_author->num_rows; //check see if reviews have been found. if($author_found_count == 0) { //no reviews found. exit ("you not author of review. not authorised delete it."); }
you trying num_rows of php array, purpose should use mysqli_result object:
$author_found_count = $search_author->num_rows;
you can use php function check if result set empty:
$author_found_count = count($found_author);
Comments
Post a Comment