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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:37:19+00:00 2026-06-06T03:37:19+00:00

So I’m writing a PHP class called article and it has a bunch of

  • 0

So I’m writing a PHP class called article and it has a bunch of methods like insert, delete and update. I have 3 other functions that follow the same code and they all work so I don’t know why I am getting this error. Here is the code I wrote.

public function update(){

    //make sure that the article does have an I.D
    if(is_null($this->id)) trigger_error("Article::update(): Attempt to update an Article object that does not have its ID property set.", E_USER_ERROR );

    //If there are any PDO errors they will be caught.
    try{
        $connection1 = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD);
        $connection1->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
        $sqlQuery = "UPDATE articles SET lastEditDate=FROM_UNIXTIME(:lastEditDate), lastEditUser=:lastEditUser, title=:title, content=:content WHERE id = :id";
        $statement->prepare($sqlQuery);
        $statement->bindValue(":lastEditDate", $this->lastEditDate, PDO::PARAM_INT);
        $statement->bindValue(":lastEditUser", $this->lastEditUser, PDO::PARAM_STR);
        $statement->bindValue(":title", $this->title, PDO::PARAM_STR);
        $statement->bindValue(":content", $this->content, PDO::PARAM_STR);
        $statement->bindValue(":id", $this->id, PDO::PARAM_INT);
        $statement->execute();
        $connection1 = null;

    }


    catch(PDOException $e){
        echo "update():I'm sorry, Dave. I'm afraid I can't do that.";  
        file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
    }


}

I read that you can get it from previous queries so I tried renaming and setting a bunch of the variables to null. I also checked the other threads I could find from this site and other and almost all of them were scope issues, which I don’t think is the problem here since all my other functions work. Is there something painfully obvious that I’m missing?

  • 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-06T03:37:21+00:00Added an answer on June 6, 2026 at 3:37 am

    It should be $connection1->prepare(), not $statement->prepare().

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.