I’m posting an array of User ID’s which I want to save into a database.
My array is working, here’s a var_dump
>
array(2) { [0]=> string(3) “108” [1]=> string(2) “47” }_
Here’s an error
Fatal error: Uncaught Error: Call to a member function bind_param() on bool in /home/public_html/user.php:176 Stack trace: #0 /home/public_html/user-update.php(19): User->updateTable(Array) #1 {main} thrown in /home/public_html/user.php on line 176
[code]
$User->updateTable(array($Users));
[code]
public function updateTable(array $POSTarray){
$Db = new Dbh;
$con = $Db->connect();
foreach ($POSTarray as $p => $myId){
$sql = “INSERT INTO `mytable` (id`, timestamp`, `userId`) VALUES (?, ?, ?)”;
$stmt = $con->prepare($sql);
$id = $this->id;
$time = time();
$stmt->bind_param(‘iii’, $id, $time, $myId);
$stmt->execute();
}
return true;
}