SELECT SUM PHP MySQL problem
<p>This is driving me nuts!  Below you will find my PHP/MySQL code but I will post the direct mySQL statement here:</p>

<pre><code>   SELECT SUM( ot.value ) AS msa
     FROM orders o
LEFT JOIN orders_total ot ON ot.orders_id = o.orders_id
    WHERE ot.class = 'ot_total'
      AND UNIX_TIMESTAMP( o.date_purchased ) &gt;=1262332800
      AND UNIX_TIMESTAMP( o.date_purchased ) &lt;=1264924800
      AND o.sales_rep_id = '2'
</code></pre>

<p>When I execute this statement inside of phpMyAdmin I get the sum for ot.value which is associated to "msa".  Although, when I run my php code it does not return a value.  Anyone see the problem?</p>

<pre><code>// works in phpMyAdmin but not displaying during PHP execution!
$monthly_sales_amount_sql = "SELECT SUM(ot.value) AS msa 
                               FROM orders o 
                          LEFT JOIN orders_total ot ON ot.orders_id = o.orders_id 
                              WHERE ot.class = 'ot_total' 
                                AND UNIX_TIMESTAMP(o.date_purchased) &gt;= $start_timestamp 
                                AND UNIX_TIMESTAMP(o.date_purchased) &lt;= $end_timestamp 
                                AND o.sales_rep_id = '" . $sales_rep_id . "'";                                       

$result = mysql_query($monthly_sales_amount_sql);
$row = mysql_fetch_assoc($result); 

echo "MSA: " . $row['msa'] . "&lt;BR&gt;&lt;BR&gt;";
</code></pre>
