I'm trying to insert prepared statemant multiple values in my database through these two queries, which are both malfunctioning, returning either
Uncaught Error: Call to undefined method mysqli_stmt::bindValue()
for the first code or
Uncaught ValueError: mysqli_stmt::execute(): Argument #1 ($params) must be a list array
for second one. When I type list
instead of array
, it says
syntax error
notice all variable, table and column names are a simplified variant
I've seen a lot of similar questions, but none of them answer my problem. Not even the one that this is the 'duplicate' of.
Does anyone have a solution, or, maybe, an alternative?
Here are the two codes:
if(isset($_POST['ID'], $_POST['atr1'])){
$sql = $db -> prepare("INSERT INTO some_table (ID, atr_place) VALUES (':fir', ':sec')");
$sql -> bindValue(':fir', $_POST['ID'],);
$sql -> bindValue(':sec', $_POST['atr1'],);
$sql -> execute();
}
$sql = $db -> prepare("INSERT INTO some_table (ID, atr_place) VALUES (:fir, :sec)");
$sql -> execute(array(
':fir' => $_POST['ID'],
':sec' => $_POST['atr1'],
));