MYSQL COUNT(*) Resource Error - Programmers Heaven

Howdy, Stranger!

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

Categories

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.