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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:14:05+00:00 2026-05-26T22:14:05+00:00

I had the following piece of code with PDO prepared statements : $stmt =

  • 0

I had the following piece of code with PDO prepared statements:

$stmt = $conn->prepare('SELECT `myColumn1` FROM my_table '.
                       'WHERE `myColumn2`=:val LIMIT 1');
$stmt->bindValue(":val", $value);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);

This works fine. It sends the following query:

113 Query   SELECT `myColumn1` FROM my_table WHERE `myColumn2`=":val" LIMIT 1

and it returns the correct value.

But it doesn’t work if I change the first line to

$stmt = $conn->prepare('SELECT `myColumn1` FROM my_table '.
                       'WHERE `myColumn2`=":val" LIMIT 1');

or

$stmt = $conn->prepare('SELECT `myColumn1` FROM my_table '.
                       'WHERE `myColumn2`=':val' LIMIT 1');

The same query is sent, but PDO returns false.

Can anybody explain why?

  • 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-26T22:14:06+00:00Added an answer on May 26, 2026 at 10:14 pm

    From the page you quote:

    The parameters to prepared statements don’t need to be quoted; the driver automatically handles this.

    The purpose of the quotation marks is to delimit string data from the rest of the query, since it cannot easily be separated (unlike numbers, which have an obvious format). Since using prepared statements means that query and data are passed separately, the quotes are unnecessary.

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

Sidebar

Related Questions

If I had the following table. create_table :my_table, :id => false do |t| t.string
If I had to following file on my development branch: # file.rb class Code
I have the following piece of sql query: Sql += SELECT ISNULL(SUM(COALESCE (a.currency, 0)),
I had the following line snippet of code that searches for a propery of
I had the following code, which was basically, class foo { public: void method();
Suppose I have the following piece of code public synchronized void method() { if(something
I have a piece of code in C with the following: a = b
I get this nice piece of code from http://developer.android.com/resources/samples/ActionBarCompat/index.html , which able to make
I have the following piece of code. I've recorded the output as well: function
I had the following idea: Say we have a webapp written using django which

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.