DanielWhite Posted June 25, 2008 Share Posted June 25, 2008 Hey, Does anyone know why this won't work: mysql_query("SELECT SUM(InkCosts) FROM Stats WHERE Month='$MONTH' AND Year='$YEAR'"); The table name is correct, The $MONTH variable is working. The $YEAR variable is working. The InkCosts is the right field name. The code below; $INK = mysql_query("SELECT SUM(InkCosts) FROM Stats WHERE Month='$MONTH' AND Year='$YEAR'"); echo $INK; Prints this: Resource id #4 Thank you, Daniel White. Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted June 25, 2008 Share Posted June 25, 2008 You have to get the result of your query out of the "Resource" returned by the query... $INK = mysql_query("SELECT SUM(InkCosts) FROM Stats WHERE Month='$MONTH' AND Year='$YEAR'"); echo mysql_result($INK, 0); Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted June 25, 2008 Share Posted June 25, 2008 or: $INK = mysql_query("SELECT SUM(InkCosts) FROM Stats WHERE Month='$MONTH' AND Year='$YEAR'"); $INK = mysql_fetch_array($INK); $INK = $INK['SUM(InkCosts)']; echo $INK; Quote Link to comment Share on other sites More sharing options...
DanielWhite Posted June 25, 2008 Author Share Posted June 25, 2008 Thank you very much :-) I'm using this one: echo mysql_result($INK, 0); 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.