Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9192487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:56:09+00:00 2026-06-17T20:56:09+00:00

The solution to this problem might be a simple over sight of mine. I

  • 0

The solution to this problem might be a simple over sight of mine.

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?

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;

I am executing the query like this;

$result = mysql_query($this->query);

$this->query is a string which holds the above query, as it is displayed to you above.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:56:11+00:00Added an answer on June 17, 2026 at 8:56 pm

    The problem is mysql_query() doesn’t support multiple queries. Your SET @running_sum = 0; is considered a separate query and so you’ll have to execute that first:

    $result1 = mysql_query("SET @running_sum = 0;");
    
    $result2 = mysql_query($this->query); // <-- without the SET ... query
    

    From the Manual:

    mysql_query() sends a unique query (multiple queries are not supported)


    Side note: The mysql_* library is deprecated, it is recommended to upgrade to a modern MySQL library such as PDO or MySQLi.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There must be a simple solution to this problem but for the love of
Hope to get solution to this problem. I have been stuck on it since
What is the solution to this problem? I added a mouse listener to a
I cannot find the solution for this problem, here is the simplified example: On
I was thinking of a solution to this problem. My input: 1. Have a
I have been struggling to find a solution to this problem. In my code,
I've been spending hours looking for a solution on this problem. As you can
I'm looking for the generally accepted/best solution to this problem. Problem I have a
Can anyone give me a cross-browser supported solution for this problem?
I'm sure there is some really easy solution to this problem, at least it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.