I have finally figured out how to use array elements as a part of a WHERE clause, but now I am not sure if the following query is protected against SQL injection.
$elements = ( implode ( "', '", $array ) );
if ( $stmt = $mysqli -> prepare ( "SELECT * FROM config_errors WHERE error_assoc_id IN ('$elements') AND row_type = ?" ) ) {
$row_type = "some_value";
$stmt -> bind_param ( "s", $row_type );
...
}
To be honest, I am very deficient in this regard. Thanks for any advice.
EDIT (@Wing Lian)
It's not the important thing but $array
is created in another statement:
$array = array();
if ( $stmt = $mysqli -> prepare ( "SELECT * FROM config_errors WHERE row_type = ? AND error_type = ?" ) ) {
bind params
execution of the query and the result
mysqli_num_rows condition
while $row loop
value (characters) conditions
array_push ( $array, $row['value'] );
}
Let's assume that the array is created from inputs of some form.