Jump to content

Counting number of rows in a table (SQL)


oha055

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.