PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1848
Number of posts: 5016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
MYSQL COUNT(*) Resource Error Posted by chads2k2 on 29 Aug 2002 at 1:23 PM
Hello. I have a problem which someone may know how to fix check this out:

Which I am sure someone here knows. Check this out ::

$sql7 = "select COUNT(*) from brokers where status='Active'";
$brokernumber = mysql_query($sql7);

Connection and everything is ok and connected correctly. So don't worry about that. Yes the table is named brokers and there is a field named status and yes atleast one has Active in it. Now I tried to do a
<?php
echo "$brokernumber";
?>

All the other COUNT(*)'s I have done like this work fine... But when I do two more it just gives me this saying "Resource id #10" where the variable is. Great.. Now what does this mean? The other ones I did I added together and got the answer and put it back out. I have tired doing:

$sql7 = "select COUNT(*) from brokers where status='Active'";
$brokernumber = mysql_query($sql7);
$brokernumbers = $brokernumber;

<?php
echo "$brokersnumbers";
?>

Still no luck. Do I have to add something to it to get an accurate reading out of it? Thank you very much and have a great day!

Report
Re: MYSQL COUNT(*) Resource Error Posted by releasedj on 6 Sept 2002 at 5:18 AM
When you do:

$brokernumber = mysql_query($sql7);

.. $brokernumber becomes the result resource. You must then use other mysql functions to access the resource to get the desired result, so you would do:

$sql7 = "select COUNT(*) from brokers where status='Active'";
$result7 = mysql_query($sql7);
$brokernumber = mysql_reqult($result7,0);

echo $brokernumber




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.