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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:43:36+00:00 2026-06-03T13:43:36+00:00

I’m trying to edit an INSERT query using bindParam(). Here is my code. public

  • 0

I’m trying to edit an INSERT query using bindParam().

Here is my code.

public function addProduct()
{
   $query = "INSTERT INTO producten (name, model, price, image, description) 
   VALUES (:name, :model, :price, :image, :description)";

   $stmt = $this->dbh->prepare($query);


   $stmt->bindParam(":name", $_POST['name']);
   $stmt->bindParam(":model", $_POST['model']);
   $stmt->bindParam(":price", $_POST['price']);
   $stmt->bindParam(":image", $_FILES['file']['name']);
   $stmt->bindParam(":description", $_POST['description']);

    print_r($stmt);
}

$dbh object is created in the contruct function of the class;

public function __construct()
    {
       $user = "root";
       $pass = "";

       $this->dbh = new \PDO('mysql:host=localhost;dbname=projectname', $user, $pass);

    }

The $stmt->bindParam() returns true when tested but does not replace the given parameters.

Does anyone know what i’m doing wrong?

  • 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-03T13:43:37+00:00Added an answer on June 3, 2026 at 1:43 pm

    The whole idea about prepared statements is that you don’t need to inject your raw parameters into the query to compose some SQL code with escaped data. Instead, you use simple place-holders and keep the data somewhere else. When the query needs to be run, you feed the database engine with both pieces of data (the SQL query with place-holders and the values that correspond to those place-holders) and the database itself takes care of the rest.

    So:

    1. PDO will not edit your query. It doesn’t need to.
    2. You still need to run the query. The “prepare” phase simply links a place holder with a variable, so the value can be read from the appropriate location when the query runs.
    3. You can actually prepare once and run many times with different parameters.

    Note: some PDO drivers don’t allow regular prepared statements (for instance, because the underlying DB engine does not fully support them). In that case, PDO will emulate prepared statements and actually perform good old escaping. But since PDO is an abstraction layer, this shouldn’t change the way you deal with it.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

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.