oha055 Posted October 5, 2011 Share Posted October 5, 2011 Hi, I have a problem regarding counting rows in a mysql table. Here is the code: <?php require_once('includes/connection.inc.php'); $conn = dbConnect('read'); $check = 'SELECT COUNT(*) FROM images'; $checkRes = $conn->query($check) or die(mysqli_error()); if($checkRes <= 0) { header('Location: empty_blog.php'); // redirect to another page } else { // do something else... } ?> The error I'm getting: "Notice: Object of class mysqli_result could not be converted to int in C:\xampp\htdocs\photoblog\index.php on line 6" Any help is greatly appreciated! Link to comment https://forums.phpfreaks.com/topic/248500-counting-number-of-rows-in-a-table-sql/ Share on other sites More sharing options...
requinix Posted October 5, 2011 Share Posted October 5, 2011 You aren't using mysqli correctly. Read the manual, and pay special attention to the bits about mysqli_result. Link to comment https://forums.phpfreaks.com/topic/248500-counting-number-of-rows-in-a-table-sql/#findComment-1276143 Share on other sites More sharing options...
oha055 Posted October 5, 2011 Author Share Posted October 5, 2011 Ok, thank you. I'll do that. Link to comment https://forums.phpfreaks.com/topic/248500-counting-number-of-rows-in-a-table-sql/#findComment-1276147 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.