Ambiguous Query Results

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Harlequin
Forum Commoner
Posts: 51
Joined: Tue Sep 21, 2004 10:51 am
Location: UK

Ambiguous Query Results

Post by Harlequin »

Hi all. I'm hoping someone with more knowledge than me can help with this little canundrum...

I have the following query:

Code: Select all

// Count Total Users: 
   $Query11 = "SELECT COUNT(*) FROM MembersData
   WHERE ID != ''"; 
   $Result11 = mysql_query($Query11) or die("Error 11: " . mysql_error()); 
   $UsersTotal = mysql_result($Result11, 0);
Which counts the number of records. However, if I echo the results on screen I get 136 but if I stuff them into a tale I get 127.

Mad, I know but it's true...!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What is the code you are using to echo the results and what is the code used to insert them into a table?

BTW, you can save your database some effort by doing COUNT(ID) instead of COUNT(*):

Code: Select all

SELECT COUNT(ID) FROM MembersData WHERE ID <> ''
Mac
Post Reply