Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

MYSQL COUNT(*) Resource Error

chads2k2chads2k2 Posts: 1Member
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!

Comments

  • releasedjreleasedj Posts: 2Member
    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

Sign In or Register to comment.