I have been refered before to the general answered question "How can I prevent SQL injection in PHP?". The advantages to use prepared queries are clearly illustrated. The simple SELECT...WHERE query is mostly used as illustration:
$stmt = $pdo->prepare('SELECT * FROM employees WHERE name = :name');
$stmt->execute([ 'name' => $name ]);
I am trying to use it ("cloning" it as far as I can) in an UPDATE...SET...WHERE with the following query:
$stm = $pdo->prepare("UPDATE `$databasetable_final` SET `Id_1`= :name
WHERE Id_S BETWEEN $Row_From AND $MaxId) ");
$stm->execute(['name'=>$Id_SB]);
I get a fatal error with the message:
execute( $bound_input_params = ['name' => 11] )
refering to a problem with the parameters specification (although the desired value (11) of $Id_SB seems to be correctly retrieved).
Evidently, I do not understand the parameters structures to be used. In particular should I declare an Array for the 'name' parameter? Detailed basic explanations would be appreciated. Thanks in advance.