monkeytooth Posted April 28, 2010 Share Posted April 28, 2010 I've tried this multiple times, it used to work like a charm too, lately though not so much. I have tried to count them 2 ways.. One: $totalcount_query = "SELECT COUNT(*) AS totalcount_rows FROM ".$tableName." ".$appndQ.""; $totalcount_result = mysql_query($totalcount_query) or die('Error #SQL0003: Query Failed.'); $totalcount_row = mysql_fetch_array($totalcount_result, MYSQL_ASSOC); $totalcount = $totalcount_row['totalcount_rows']; I run these within a function I created to make my code smaller in other areas of the site... Now thing I should mention is that these still work I get record counts.. the issue with them is when ever I add an "AND" to my clause it fails. Sometimes I require to find out if something or not already with a particular person so I want to count records like WHERE user='$userID' AND itemID='$itemID' The Above fails.. every time as far as getting a count with either mentioned at the top methods. Now if I do the same thing minus the AND WHERE user='$userID' or WHERE itemID='$itemID' I get an actual count. Where am I getting this wrong? Two: $result = mysql_query("SELECT * FROM ".$tableName." ".$appndQ.""); $totalcount = mysql_num_rows($result); Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted April 28, 2010 Author Share Posted April 28, 2010 Wow, managed to somehow messed up my post "One" and "Two" are my attempts to query that fail when i add AND to the syntax Quote Link to comment Share on other sites More sharing options...
jdavidbakr Posted April 29, 2010 Share Posted April 29, 2010 What's the output of mysql_error() when the query fails? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.