DrTrans Posted October 28, 2009 Share Posted October 28, 2009 Getting the same count everytime $visitquery = mysql_query("SELECT COUNT(*) FROM visitors WHERE ownerkey = '$uuid' & region = '$selected' AND `date` < DATE_ADD(CURDATE(), INTERVAL +7 DAY)", $connect); $row9 = mysql_fetch_array($visitquery); $visitoramount = $row9[0]; print "[$visitoramount] visits in the last 7 days!"; If $selected = "Blah" it gives the count as " 8" if $selected = "Dumb" it gives the count as "8" ... Al though there is no "Dumb" in the db. Sorry if my explaining is off. Just dont know another way to explain it easier. Quote Link to comment https://forums.phpfreaks.com/topic/179305-solved-count/ Share on other sites More sharing options...
DavidAM Posted October 28, 2009 Share Posted October 28, 2009 I don't think you can use the '&' in a WHERE clause, change that to AND: $visitquery = mysql_query("SELECT COUNT(*) FROM visitors WHERE ownerkey = '$uuid' AND region = '$selected' AND `date` < DATE_ADD(CURDATE(), INTERVAL +7 DAY)", $connect); By the way, shouldn't that be "date > CURDATE - 7" ? I mean if you are looking for the number of visits in the past seven days. Your query specifies all dates less than NEXT WEEK; that would probably be all of them. Quote Link to comment https://forums.phpfreaks.com/topic/179305-solved-count/#findComment-946038 Share on other sites More sharing options...
DrTrans Posted October 28, 2009 Author Share Posted October 28, 2009 Gives result of "0" all across . And also did that -7 days. Quote Link to comment https://forums.phpfreaks.com/topic/179305-solved-count/#findComment-946040 Share on other sites More sharing options...
DavidAM Posted October 28, 2009 Share Posted October 28, 2009 Check the values of $uuid and $selected before the query is executed. Check your database using those values and look at the dates (select *). Is there actually data there that should be counted? Quote Link to comment https://forums.phpfreaks.com/topic/179305-solved-count/#findComment-946049 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.