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

  • Home
  • SEARCH
  • 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 7624819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:04:15+00:00 2026-05-31T05:04:15+00:00

I am using php PDO and I have this error when I use the

  • 0

I am using php PDO and I have this error when I use the query below,

SQLSTATE[HY000]: General error

query,

            CREATE TEMPORARY TABLE temp_tb 
            SELECT * FROM person;

            ALTER TABLE temp_tb 
            DROP type;
            SELECT * 
            FROM temp_tb AS p

            LEFT JOIN user AS u
            ON p.person_id = u.person_id

            LEFT JOIN category AS c
            ON u.category_id = c.category_id

            WHERE u.signature = ?

They query is to create a temp table and then to drop a column from that temp table, then join it with other tables.

It returns result OK when I query it directly on phpMyAdmin but not through PDO. Something I have done wrong in the query or the PDO? How can I get around to this?

EDIT:

PDO,

public function fetch_object($query, $params = array())
    {
        try
        {
            # prepare the query
            $stmt = $this->connection->prepare($query);

            # if $params is not an array, let's make it array with one value of former $params
            if (!is_array($params)) $params = array($params);

            # execute the query
            $stmt->execute($params);

            # return the result
            return $stmt->fetchObject();
            //return $stmt->fetch(PDO::FETCH_OBJ);
        }
        catch (PDOException $e) 
        {
            # call the get_error function
            $this->get_error($e);
        }
    }

$user = $this->database->fetch_object($sql,$authenticated_user);

error,

SQLSTATE[HY000]: General error

  • 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-05-31T05:04:16+00:00Added an answer on May 31, 2026 at 5:04 am

    The problem is that you use several queries in one call (create temp table, alter it and then select from it). Read about multiple queries in one call here

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

Sidebar

Related Questions

I often see something similar to this below in PHP scripts using MySQL query(SET
I am using PDO with PHP to create a new database and then a
using php and mysql I have two tables, a users table and a profiles
I have a problem in a php script where I am using PDO to
I have two computers with two Postgre databases. I am using PHP with PDO
I'm using PHP PDO to run queries. I have the following function: protected function
I am using pdo in php and the error i am getting is: Product
I have two databases, one's MySql, one's MSSQL, I'm using php::pdo on both, except
My first real foray into using PHP OOP and PDO extensively. I have finally
Possible Duplicate: PDO Prepared Statements I'm using the mysqli extension in PHP and I'm

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.