How do I go about debugging a prepared select statement with variable binding Mysqli in PHP? - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Friday, January 28, 2022

How do I go about debugging a prepared select statement with variable binding Mysqli in PHP?

I have the following, which works:

$sql = "SELECT * FROM SOMETABLE WHERE name='music'";
$stmt = $conn->prepare($sql);
$stmt->execute();

However, when I try to do it with variable binding, it does not:

$item_name = "music";
$sql = "SELECT * FROM SOMETABLE WHERE name='?'";
$stmt = $conn->prepare($sql);
$stmt->bind_param('s', $item_name);
$stmt->execute();

How can I go about figuring out why it doesn't?



source https://stackoverflow.com/questions/70883670/how-do-i-go-about-debugging-a-prepared-select-statement-with-variable-binding-my

No comments:

Post a Comment