Answer the question
In order to leave comments, you need to log in
How to pass a variable to SQL query?
The code works fine
echo json_encode(R::getAll('SELECT * FROM `category` WHERE `id_user` = 100'));
$id_user = 100;
echo json_encode(R::getAll('SELECT * FROM `category` WHERE `id_user` = $id_user'));
Answer the question
In order to leave comments, you need to log in
Who teaches you redbin, without even giving the basic syntax?
A variable is never passed directly to a request. It must be submitted separately.
echo json_encode(R::getAll('SELECT * FROM `category` WHERE `id_user` = ?', [$id_user]));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question