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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:13:29+00:00 2026-06-17T11:13:29+00:00

I am confuse between these two functions Bindvalue() and BindParam() I read on php.net

  • 0

I am confuse between these two functions Bindvalue() and BindParam()

  1. I read on php.net it does not escape % and _, so be careful when using LIKE. So i think BindValue() is not used when we are using LIKE query.
  2. when we using LIKE query BindParam() is used. Because as i know BindParam can escape these % and _.
  3. BindValue() doesn’t gives protection against sql injection. I am not sure about this, is it true?

friends tell what i mention in these 3 points is right or wrong.
i am beginner in PDO so please explain it clearly ..

  • 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-17T11:13:30+00:00Added an answer on June 17, 2026 at 11:13 am

    There should be no difference in how values are escaped or not escaped. bindParam differs from bindValue in that it references the variable, binding the value only when you execute the statement. bindValue takes the value immediately. To illustrate:

    $stmt = $db->prepare('SELECT * FROM `table` WHERE foo = :foo');
    
    $foo = 'foo';
    $stmt->bindValue(':foo', $foo);
    $foo = 'bar';
    
    $stmt->execute();
    

    The above executes like SELECT * FROM table WHERE foo = 'foo';

    $stmt = $db->prepare('SELECT * FROM `table` WHERE foo = :foo');
    
    $foo = 'foo';
    $stmt->bindParam(':foo', $foo);
    $foo = 'bar';
    
    $stmt->execute()
    

    The above executes like SELECT * FROM table WHERE foo = 'bar'.

    It’s true that neither cares about _ or % as special characters, because generally speaking they aren’t special characters as far as the syntax is concerned, and the database driver is not able to analyze the context to figure out whether you mean % to be a wildcard or the actual character “%” in the context of a LIKE query.

    Both protect against SQL injection.

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

Sidebar

Related Questions

I am confused between these two functions: void Swap_byPointer1(int *x, int *y){ int *temp=new
I am confused on the differences between these two code blocks: $(#someButton).click(function() { var
I am very confused between these functions and their purposes. What I have observed
I am confused and couldn't figure out the difference between these two lines!! echo
I'm confused about the differences between these two special folders. Here's a code snippet
I am confused between the differences between these two applications while trying to setup
Im quite confused that what is difference between these two initializations: int (*p)[10]; and
I'm confused about the difference between these two things: $env:path And function path {$env:path}
So, I know that there is a difference between these two tidbits of code:
What is the difference between these two lines of code? int *ptr = &x;

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.