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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:39:12+00:00 2026-06-15T08:39:12+00:00

I have been pulling my hair out trying to swap my current script over

  • 0

I have been pulling my hair out trying to swap my current script over to PDO. I have simplified the MySQL query for this example, but the error remains even with this version.

$sql = 'SELECT * FROM :table WHERE lastUpdate > :appDate';

try{
    $db = connect();
    $stmt = $db->prepare($sql);
    $stmt->bindParam(':table', $table);
    $stmt->bindParam(':appDate', $appDate);

    foreach($tablesToCheck as $table){
        $stmt->execute();
        $resultset[] = $stmt->fetchAll();
    }
} catch(PDOException $e){
    print 'Error!: '.$e->getMessage().'<br/>';
}//End try catch

$stmt->errorInfo() returns:

( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the 
right syntax to use near ''GroupName' WHERE lastUpdate > NULL' at line 1 )
  • 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-15T08:39:14+00:00Added an answer on June 15, 2026 at 8:39 am

    Here is the revised code with Michael’s help:

    foreach($tablesToCheck as $table){
        $sql = 'SELECT *, \''.$table.'\' AS tableName FROM '.$table.' WHERE lastUpdate > :appDate';
    
        try{
            $db = connect();
            $stmt = $db->prepare($sql);
            $stmt->bindParam(':appDate', $appDate);
            $stmt->execute();
    
            while($row = $stmt->fetch(PDO::FETCH_ASSOC))
                $resultset[] = $row;
    
        } catch(PDOException $e){
            print 'Error!: '.$e->getMessage().'<br/>';
        }//End try catch
    }//End foreach
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been pulling my hair out trying to make this work. I have
I have been pulling my hair trying to figure this out but nothing is
I've been pulling out my hair trying to figure this problem out. I have
I have been pulling my hair out trying to solve this. What I am
I have been pulling out my hair trying to figure out why this is
I literally have been pulling my hair out over this for a few days
I have been having this problem and been pulling my hair out over it.
I have been pulling my hair out trying to figure out what I can't
I have been pulling my hair out about this since Friday and I am
I've been pulling my hair out this morning trying to figure this out. I

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.