I'm getting the following two warnings when I hit my database.
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /data/web/html/folder/buildoutput.php on line 183
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /data/web/html/folder/buildoutput.php on line 187
I have echoed my sql statement because it's being build dynamically. My first sql statement looks like this:
SELECT count(money) AS tot, round(sum(money),0) AS value
FROM mainTable
WHERE xt = '2'
AND ADate BETWEEN '2005-10-01' AND '2005-12-29'
AND code not in ('x','y','z')
When I cut/paste it into mysqlyog, the correct results are returned. Which are tot = 0 and value = NULL. 'ob' is a bigint, but the default is set to NULL. Is this where my problems is? Should the default be set to 0?
Or is this an entirely different problem. What I want to do is:
if tot = 0, then I push a 0 into my variable,
else, I push value in.
Do I need to do this in 2 seperate sql statements? The first one to check the count and if it's > 0, submit the sql statement to sum the field?