Good morning again,
This piece of code has stumped for me the last 4 hours. The first issue I solved on this post and was user error.
The second bit seems more technical which I’m not sure how to fix. As per my other thread. I’m passing in an array to my object and now within a method I want to foreach loop through that array and insert each one into a database.
There may be better ways of achieving this and I’m open to those. I’ve been writing PHP for only a few months so please excuse me.
Here is my code
[code]
$students= $this->studentList;
foreach ($students as $key => $value) {
$stmt3 = $con->stmt_init();
$stmt3->prepare(“INSERT INTO `studentList` (`objectVal0`, `objectVal`, `objectVal2`) VALUES (?, ?, ?)”);
$student = $students[$key];
$stmt3->bind_param(‘iii’, $var1, $var2, $student);
$stmt3->execute();
}
When I dump my original object I get this
“`
‘studentList’ =>
array (
0 => ’10’,
1 => ’65’,
),
**My error is :