r/PHP•
Maleficent-Ad-9754

what am I doing wrong?

Discussion
I prepare an SQL statement in a function as:
 $id = (int) $id;
 $sql = "SELECT `price` FROM `rooms` WHERE `id` = $id";

This won't work, but if I change $id to a hard value such as 8, it works:
$sql = "SELECT `price` FROM `rooms` WHERE `id` = 8";

Posted Aug 13, 2026, 4:51 PM UTC

023
Loading comments…