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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:29:25+00:00 2026-06-06T02:29:25+00:00

Possible Duplicate: Retrieve (or simulate) full query from PDO prepared statement I can’t figure

  • 0

Possible Duplicate:
Retrieve (or simulate) full query from PDO prepared statement

I can’t figure out why my query is returning 0 rows.. it implements some very dynamic search functionality, and a lot of if/loop statements etc. Therefor to debug it, I’d like to see EXACTLY what string is being sent to the server. Is there a way to do this through PHP?

Is there maybe a way to ask the server “what was the last query”, or tell PDO “show me what you sent”?

I saw one response using str_replace to manually enter the values in place of :fieldValue, but it’s likely a syntax problem (or maybe it’s going through an incorrect loop, etc), which this method doesn’t help with.

Using bindValue(":fieldValue", $value); if that makes a difference.

EDIT

Turns out it was a simple if ($var="true") { ... which should have been if ($var=="true") { .... PHP I guess is not the same as Java in that sense? Either way, the question still stands (as I run into this often). I had to use a series of echo "You are Here"; to find this error, as it was technically valid but not correct. If I had the final SQL statement, I could have seen “Oh, my code has added the where column = true, must have gone through the wrong IF…”.

  • 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-06T02:29:26+00:00Added an answer on June 6, 2026 at 2:29 am

    That’s the single most common myth about SQL debugging. “I need to see the query after preparation to be able to tell if an error occurred”. The fact is, you don’t, and I’ll tell you why.

    Once a query has been prepared, the placeholder can be considered as a valid string/integer. You don’t care what’s in it.

    Also, if you set up PDO correctly, you’ll get a detailed PDOException detailing the error you’ve had along with a complete backtrace of where the error happened, plus you get the error string from MySQL, which makes syntax errors very easy to find.

    To enable PDO Exceptions and disable emulated prepares:

    $pdo = new PDO("mysql:host=localhost;dbname=database_name", "user", "password");
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: get all available fonts from google font api How we can retrieve
Possible Duplicate: How to Capitalize names using C# How can i retrieve values from
Possible Duplicate: Can I retrieve an ipad unique device identifier that through Safari with
Possible Duplicate: How to retrieve the values for the particular key from CFMutableDictionary In
Possible Duplicate: How to retrieve and display images from a database in a JSP
Possible Duplicate: How can I retrieve recently used contacts in android? I want to
Possible Duplicate: How can i avoid Location service in AlAssetLibrary? Can i retrieve files
I want to retrieve all case-insensitive duplicate entries from an array. Is this possible
Possible Duplicate: Python: Retrieve items from a set Consider the following code: >>> item1
Possible Duplicate: Matlab gives wrong answer Can anyone explain to me why the following

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.