michaeln82 Posted September 26, 2008 Share Posted September 26, 2008 I'm having a heck of a time getting a row count: $query2 = "SELECT COUNT(nannies.nannisBulk) AS 'myRowCount' FROM nannies, nanniesBulk WHERE nannies.nannyID = nanniesBulk.nannyID $conditions_sql $zip_sql AND status = 2 AND visible = 1 AND removed = 0"; $result2 = mysql_query($query); if ($row2 = mysql_fetch_array($result2)) { $myRowCount = $row2['myRowCount']; die($myRowCount); } else { $rowCount = 0; } When I run this, I get no output at all. If I try "die($query2)" and then cut/paste the query directly into phpMyAdmin it outputs "5" as the number of rows. If I try "$myRowCount = $row2[0]" i get 3 (instead of 5)! WTF is going on? Thanks! Link to comment https://forums.phpfreaks.com/topic/125998-troulbe-with-the-count/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 26, 2008 Share Posted September 26, 2008 If that is your actual code, the following line is using the wrong variable name in the mysql_query() statement - $result2 = mysql_query($query); Link to comment https://forums.phpfreaks.com/topic/125998-troulbe-with-the-count/#findComment-651565 Share on other sites More sharing options...
michaeln82 Posted September 26, 2008 Author Share Posted September 26, 2008 Oops. Normally I catch those... Thanks! Link to comment https://forums.phpfreaks.com/topic/125998-troulbe-with-the-count/#findComment-651568 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.