Jump to content

[SOLVED] printing the query within a mysqli_stmt?


eburroughs

Recommended Posts

I'm using prepared mysqli_stmt variables in an object-oriented fashion to communicate with my MySQL server. Something's not quite right with the SQL statement I prepared, and I want to print out the query to see what's wrong with it, but I can't find a way to print out the query held within a mysqli_stmt object. I'm used to doing things the old fashioned way where you just define a query in a (easily printable) string and pass that to mysql_query().

 

How do I print the query held inside a mysqli_stmt?

Link to comment
Share on other sites

Sure:

 

$conn = new mysqli("********","****","*****","*****");

....

$statement = $conn->prepare("INSERT INTO foo VALUES(?,?,INET_ATON(?),NOW())");
$statement->bind_param('sss', $string1, $string2, $_SERVER['REMOTE_ADDR']);
$statement->execute();
$statement->close();

 

My query is executing, but not doing exactly what I want. I would like to see the raw text of the SQL query. I've tried print_r($statement) and var_dump($statement), but they don't give me the info I need.

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.