Show MySQL query

Quick question. How can I echo out the a query in php that I’m trying to debug so that it shows all the variables in the query used. I’ve tried searching but haven’t seen anything which does it.

Do I have to use something like print_r()? I have a query and just need to see what the query is generated like.


ok cheers, thought it was not as easy as that somehow… will try it


Method 1: store the query as a variable.

$sel = "SELECT blah FROM table WHERE stuff = $stuff";
$res = mysql_query($sel);
echo $sel;

Method 2: copy the query line, but replace mysql_query with echo.

mysql_query("UPDATE $table SET $values");
echo("UPDATE $table SET $values");