Page 1 of 1

Counting rows in MySQL don't work

PostPosted: 05. November 2013 22:09
by sigve1109
I use this code to count rows and tell if no rows is found.

Code: Select all
     $check_tickets = mysqli_query($con,"SELECT count(*) FROM tickets");
     if (mysqli_num_rows($check_tickets) > 0)
     {
       echo "no rows";
     }


This is pretty standard, right? But when using it on localhost (xampp), I always get "no rows" even if there is plenty of rows.
When using my scripts on a shared server everything works just fine! What can possibly be wrong when it's working on a
hosted shared server, but not on the latest install of xampp?

Re: Counting rows in MySQL don't work

PostPosted: 05. November 2013 22:40
by Nobbie
sigve1109 wrote:This is pretty standard, right?


No, this is pretty wrong. It is just vice verse: if mysqli_num_rows() retuns a value greater than zero, then this is the number of rows.