I need to get the last value of numAlarms
and Update it if exist and insert it if it's not exist
if (isset($_POST['send'])) {
if (isset($_GET['stdId'])) {
$stdId = $_GET['stdId'];
}
if (isset($_GET['subR'])) {
$subR = $_GET['subR'];
}
$getInc = $db->prepare("SELECT numAlarms FROM stud_abs_alerts WHERE studId=? AND sub_id=?");
$getInc->bind_param('ii', $stdId, $subR);
if ($getInc->execute()) {
$rest = $getInc->get_result();
if ($a = mysqli_fetch_array($rest)) {
$inc = $a['numAlarms'];
$increment = ++$a;
$id = "";
$numAlarms = 1;
//var_dump($rest);
$getInfo = $db->prepare('INSERT INTO stud_abs_alerts (id, studId, sub_id, numAlarms) VALUES (?,?,?,?)
ON DUPLICATE KEY UPDATE numAlarms=VALUES(?)');
$getInfo->bind_param('iiiii', $id, $stdId, $subR, $numAlarms, $numAlarms);
if ($getInfo->execute()) {
echo "done";
} else {
echo "Error";
}
}
}
}
GOT : Fatal error: Call to a member function bind_param() on a non-object