lampwins lampwins - 5 months ago 15x
SQL Question

MySQL SUM query problems php

I have the following query running in PHP:

$ticketTotal = mysql_query("SELECT SUM(`tickets_issued`) FROM `tb_att_registered_attendants` WHERE `confirmation_code`!='000000'");

But when I return
, I get
Resource id #33
and when I dump the variable, I get
resource(33) of type (mysql result)
. When I run the exact same query in phpMyAdmin, I get the correct result. I can't seem to find much on google. What is going on?

Thanks in advance for any help.


$ticketTotal doesn't hold your query results. You still have to actually fetch them.

while ($row = mysql_fetch_assoc($ticketTotal))

Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.