Can anyone tell me why the first query echoes out results, while the second query returns null in the result set?
$sql1 = '
SELECT
SQL_CALC_FOUND_ROWS
*
FROM
table1
LEFT JOIN table2 ON id_a = id_b
LEFT JOIN table3 ON id_c = id_d
WHERE id_d IS NOT NULL
AND l_type <> 2
AND l_status = 2
AND v_status >= 1
AND l_end_date >= CURDATE()
ORDER BY 1 ASC
LIMIT 20
$sql2 = '
SELECT
SQL_CALC_FOUND_ROWS
*
FROM
table1
LEFT JOIN table2 ON id_a = id_b
LEFT JOIN table3 ON id_c = id_d
WHERE id_d IS NOT NULL
AND id_d = ? //the only difference
AND l_type <> 2
AND l_status = 2
AND v_status >= 1
AND l_end_date >= CURDATE()
ORDER BY 1 ASC
LIMIT 20
I am preparing, binding and executing the placeholder parameter like every other hundreds of times in the past. I'm baffled, why won't the second query give any results?
Let me know if my question is lacking detail - my code is as simple as this so there's not much more to it at all.
I've even tried replacing the placeholder with the actual value, which is a string of numbers like 123456789
. The query works fine in phpmyadmin when I test it locally too. What could be the problem?
This is what I've tried, but no errors appear. It's just a blank page.
$stmt2 = $db->prepare($sql2);
if (false === $stmt2) {
print_r($db->error_list);
echo mysqli_error($db);
echo $stmt2->error;
}
Where $db is $db = new mysqli($dbHost, $dbUser, $dbPass, $dbName);