title: MYSQL variables in php query
body: <p>The solution to this problem might be a simple over sight of mine.</p>
  
  <p>I am trying to run a MYSQL query stored as a string in PHP. The query runs fine using DBM tool like Navicat but returns false in my PHP development enviorment. Is there something I've over looked?</p>
  
  <pre><code>SET @running_sum = 0;
  
  SELECT
      TID,
      SumTotal,
      T.`Freight`,
      T.`Insurance`,
      T.`Discount`,
      CONCAT(
          '$',
          FORMAT(
              @running_sum :=@running_sum + SumTotal + T.`Freight` + T.`Insurance` - T.`Discount`,
              2
          )
      ) AS 'Running Total'
  FROM
      (
          SELECT
              TID,
              SUM(Quantity * UnitNetValue) AS SumTotal,
              T.`Freight`,
              T.`Insurance`,
              T.`Discount`
          FROM
              Transactions T
          JOIN `Transactions_Products` P ON T.TransactionID = P.TID
          WHERE
              (
                  T.TemplateName = ''
                  OR T.TemplateName IS NULL
              )
          AND T. STATUS = 1
          GROUP BY
              TransactionID
  
      ) AS T;
  </code></pre>
  
  <p>I am executing the query like this;</p>
  
  <pre><code>$result = mysql_query($this-&gt;query);
  </code></pre>
  
  <p><code>$this-&gt;query</code> is a string which holds the above query, as it is displayed to you above.</p>