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?

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.

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.