Link to home
Start Free TrialLog in
Avatar of Nathan Riley
Nathan RileyFlag for United States of America

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nathan Riley

ASKER

Checked the query in phpmyadmin and it worked.
Heh, it's been a long day.  Had an issue with the connection to DB.  All working now thanks.
Great!  Thanks for the points, ~Ray