Populating a certain value from a field in an SQL DB

I have a MYSQL database running with a single table named 'users'.  In that table I have a field called 'account_status' which can have one of 4 values (0, 1, 2, 5).  Anyhow, what I want to do I call a php script to loop through the whole database and return the number of rows (or users) that contain a value of say, 2.  Then I would print it to my page saying 'There are 'THIS MANY' users awaiting activation".  Really simple question, but I would appreciate a quick answer. Thanks!
tridenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

carchitectCommented:
<?
$connection=mysql_pconnect("localhost","root","root");
$db=msql_select_db("database",$connection);
$sql="select * from users where account_status=2";
$res=mysql_query($sql,$connection);
$rowcnt=mysql_num_rows($res);
echo "No. of usres $rowcnt";
?>
regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tridenAuthor Commented:
Hmm, I get an error:

Warning: Supplied argument is not a valid MySQL result resource in /usr/www/cybermart/admin/main.php on line 13


This is what I have written:

$sql = mysql_query("SELECT * FROM users WHERE account_status='1'");
$result = mysql_query($sql);
$num_activation = mysql_num_rows($result);  //LINE 13

I already have the connection started in an include file.
0
tridenAuthor Commented:
Sorry about that last error, i figured it out. thanks!
0
carchitectCommented:
thx triden for accpting my answer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.