我想要如果没有给出以下消息的作者/用户出口,请尝试。但是请继续尝试尝试在$ author_found_count上获取非对象的属性。为什么是这样?谢谢
$find_author = "SELECT user FROM reviews WHERE 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 to see if any reviews have been found.
if($author_found_count == 0) {
//No reviews found.
exit ("You are not the author of the review. You are not authorised to delete it.");
}
您正在尝试获取php数组的num_rows,但是为此,您应该使用mysqli_result对象:
$author_found_count = $search_author->num_rows;
您还可以使用php函数检查结果集是否为空:
$author_found_count = count($found_author);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句