Counting rows in MySQL don't work

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Counting rows in MySQL don't work

Postby sigve1109 » 05. November 2013 22:09

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?
Posts: 1
Joined: 04. November 2013 16:50
Operating System: Windows

Re: Counting rows in MySQL don't work

Postby Nobbie » 05. November 2013 22:40

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.
Posts: 8930
Joined: 09. March 2008 13:04

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 41 guests