mysqli returning single result

I'm trying to convert some code over to mysqli from my sql but getting the error:
Fatal error: Call to a member function fetch_assoc() on a non-object in /home/prod/public_html/dashboard/leftsidebar.php on line 8

Not sure what I'm doing wrong, just trying to pull the count number.  Below is my code.

//Project Count
$sql1 = "select count(p.id) as projecttotal from projects p inner join projectassoc pa on p.id = pa.project_id where pa.user_id = $userid";
$result1 = $db->query($sql1);
$row1 = $result1->fetch_assoc();
echo $row1['projecttotal'];

Open in new window

LVL 12
Nathan RileyFounderAsked:
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.

Ray PaseurCommented:
This almost always means the query failed.  This article shows how to visualize error information.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
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
Nathan RileyFounderAuthor Commented:
Checked the query in phpmyadmin and it worked.
0
Nathan RileyFounderAuthor Commented:
Heh, it's been a long day.  Had an issue with the connection to DB.  All working now thanks.
0
Ray PaseurCommented:
Great!  Thanks for the points, ~Ray
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
MySQL Server

From novice to tech pro — start learning today.