// Get clicks
$clicks = mysql_query("SELECT
SUM(CASE WHEN clickdate = CURDATE() THEN 1 ELSE 0) AS 'numtoday',
SUM(CASE WHEN WEEK(clickdate) = WEEK(CURDATE()) THEN 1 ELSE 0) AS 'numthisweek',
SUM(CASE WHEN MONTH(clickdate) = MONTH(CURDATE()) THEN 1 ELSE 0) AS 'numthismonth',
SUM(CASE WHEN YEAR(clickdate) = YEAR(CURDATE()) THEN 1 ELSE 0) AS 'numthisyear'
FROM clicks WHERE affiliateID = '$affiliateID'");
// Check for errors
if(!$clicks){ mysql_error(); }
// Gets results from database
while($row = mysql_fetch_array($clicks, MYSQL_ASSOC)){
$clicksDay = $row['numtoday'];
$clicksWeek = $row['numthisweek'];
$clicksMonth = $row['numthismonth'];
$clicksYear = $row['numthisyear'];
}
This code tells me that $clicks is not a valid result resource? Thoughts?
Well, if it's tossing you false then you can bet that some kind of SQL error is probably occurring. Not sure why your mysql_error() call isn't giving you any additional information though. I would toy around with it. Try to concat a string to your mysql_error() call so you can at least see if it's entering your conditional.