You are using PDO and you tested the query using simple values and it is working. That means the problem happens at the parameter binding faze.
So you would like to see the SQL query PDO is generating AFTER binding all the parameters but you don't know how to. You need to find a way to do this otherwise you will end up asking here for help on every query that is not working, as you have no idea what PDO is actually generating.
Two ways to do this (I am assuming you are using WAMP, but you can adapt this to work on LAMP as well):
Method 1: We can capture every query that MySQL runs into the mysql.general_log table. By running this command:
SET GLOBAL general_log = 'ON';
SET GLOBAL log_output = 'TABLE';
To get output relevant to certain user/app from mysql.general_log table:
SELECT * FROM mysql.general_log WHERE
user_hostNOT LIKE "%root%" ORDER BY event_time DESC
OR
SELECT * FROM mysql.general_log WHERE
user_hostLIKE "%username%" ORDER BY event_time DESC
Method 2: Edit my.ini
file in WAMP to see sql query log
[wampmysqld]
general-log=1
general-log-file=c:/mysql_general.log
Also, set your connection like this to get errors thrown for both the PREPARE faze as well the EXECUTE faze:
try{
$db = new PDO('mysql:host=localhost;dbname=dbname', "username" , "password");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES,false);
}catch(PDOException $e){
print "error in connection" . $e->getMessage();
}