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 8919503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:02:37+00:00 2026-06-15T06:02:37+00:00

I have a query in my php script that is handled by PDO. To

  • 0

I have a query in my php script that is handled by PDO. To be exact it’s 2 queries in 1 statement. The query itself runs fine in SQL client (I’m using HeidiSQL). PHP however gives me exactly this error: “SQLSTATE[HY000]: General error” with nothing else. No error number or message.

Is there a way to debug the query somehow? I don’t think there’s an error in query itself, so I don’t know what’s wrong. Nothing shows in mysql error log. I’ve enabled mysql general log, but it only logs query itself without showing an error.

My stack: XAMPP 1.8, Apache 2.4.3, PHP 5.4.7, MySQL 5.5.27

This is my query (it’s rather long):

    /*First query - generating temp table with overdue jobs*/

    CREATE TEMPORARY TABLE temp AS (
        SELECT  j.NetworkID,
            @clientID := j.ClientID,
            j.BranchID,
            j.ServiceProviderID,
            (   
                (DATEDIFF(CURDATE(), j.DateBooked)) 
                - 
                IF(
                (@unit :=   (
                    SELECT      uctype.UnitTurnaroundTime
                    FROM        job
                    LEFT JOIN   product ON job.ProductID = product.ProductID
                    LEFT JOIN   unit_type AS utype ON product.UnitTypeID = utype.UnitTypeID
                    LEFT JOIN   unit_client_type AS uctype 
                            ON utype.UnitTypeID = uctype.UnitTypeID 
                            AND uctype.ClientID = @clientID
                    WHERE       job.JobID = j.JobID
                    )
                ) IS NOT NULL,      /*statement*/
                @unit,          /*TRUE - Client Unit Type has turnaround time assigned in the db*/  
                IF(         /*FALSE - Now checking if Client Default Turnaround Time is set*/
                    (@clnt := (
                        SELECT  DefaultTurnaroundTime AS dtt
                        FROM    client
                        WHERE   client.ClientID = @clientID
                    )
                    ) IS NOT NULL,  /*statement*/
                    @clnt,      /*TRUE - Client Default Turaround time is set*/
                    (           /*FALSE - falling back to general default*/
                    SELECT  gen.Default
                    FROM    general_default AS gen
                    WHERE   gen.GeneralDefaultID = 1
                    )
                )
                )
            ) AS overdue

        FROM    job AS j

        HAVING  overdue > 0
    );


    /*Second query - filtering out overdue jobs with specific time range*/

    SELECT  COUNT(*) AS number
    FROM    temp
    WHERE   overdue >= :from AND overdue <= :to AND overdue != 0

UPDATE: The problem seems to be caused by PDO refusing to run several queries in one statement. I’ve inserted this before executing query:

$conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);

So now “General error” is gone, but I’m getting

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax

just after the first query, meaning that PDO just runs one query and refuses to continue…

  • 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-15T06:02:38+00:00Added an answer on June 15, 2026 at 6:02 am

    I found a way to run several queries in one go after all. It appears MySQLi->multi_query allows this. Deeply disappointed in PDO yet again.

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

Sidebar

Related Questions

I have a php script that runs a mysql query, then loops the result,
On a webserver, I have a php script that parses a .sql file (which
I have created a PHP script that will query an LDAP server, look at
So i have this script: <?php $query = mysql_query( SELECT meetup AS text, id
Hi I have a query in PHP that calculates the sum of all the
I have a PHP/MySQL query that returns to an HTML table, and I'm stuck
I have a simple query (in a mySQL view) that php is using to
I have written a PHP script to pull a query from an Oracle database
I have nginx receiving POST requests and a tiny PHP script that puts request
I have a PHP script that generates table rows with hidden input tags that

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.