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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:25:00+00:00 2026-05-31T18:25:00+00:00

QUESTION: Why am I getting Call to undefined function prepare() error ? How can

  • 0

QUESTION: Why am I getting Call to undefined function prepare() error ?
How can I fix it?

I know this is similar to my question, but I don’t know how to apply the answer to my case.

$myNull = null;
$table="test_results";  
$sql = "INSERT INTO $table (instance, uid, testid, quizstart, quizend, score)
        VALUES (
                :instance, 
                :uid,
                :testid, 
                :quizstart,
                :quizend,
                :score)";

try {
    /*** connect to DB ***/  
    $dbh = new PDO("mysql:host=$hostname;dbname=$dbname", $username, $password);


    $stmt = $dbh>prepare($sql); //  **************ERROR HERE****************

    $stmt->bindParam(':instance', $myNull, PDO::PARAM_INT);    
    $stmt->bindParam(':uid',$userID, PDO::PARAM_INT);
    $stmt->bindParam(':testid', $tid, PDO::PARAM_STR);
    $stmt->bindParam(':quizstart', $quizstart,PDO::PARAM_STR);
    $stmt->bindParam(':quizend', $quizend,PDO::PARAM_STR);
    $stmt->bindParam(':score', $score,PDO::PARAM_STR);
    $stmt->execute();

     /*** display the id of the last INSERT ***/
    $lastInsertValue=$dbh->lastInsertId();

    $stmt->closeCursor();

    /*** close the database connection ***/
    $dbh = null;  
}
  • 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-31T18:25:01+00:00Added an answer on May 31, 2026 at 6:25 pm

    You have used greater than operator instead of arrow (->)

    $dbh>prepare($sql); //WRONG
    $dbh->prepare($sql); // CORRECT
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is very similar to this one: Getting an error in jQuery when
getting the error {error:{message:(#100) Can only call this method on valid test users for
I am getting this error: main.cpp:31: error: no matching function for call to 'QWebFrame::addToJavaScriptWindowObject(QString,
As a follow on from this question. How can I call a function and
I admit this question is getting to the limits of what I know of
I believe lot of people already asked this question before, but i kept getting
This is probably a newb question but how do I call a model that
I know this specific question has been asked before , but I am not
I am getting a compiler error of: error: no matching function for call to
This question's quite stupid, but I'm having trouble getting wpml to translate my plugin.

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.