I have a problem adding records to my database. When I try to add a record in the database, I get the following message: Parse error: syntax error, unexpected ‘$objUser’ (T_VARIABLE) in C:\xampp\htdocs\phpcrud… on line 9.
Can some please help me with this?
Here’s a snippet of the code:
$objUser = new User();
// GET
if(isset($_GET['edit_aid'])){
$aid = $_GET['edit_aid'];
$stmt = $objUser->runQuery("SELECT * FROM attendance WHERE aid = :aid");
$stmt->execute(array(":aid" => $aid));
$rowUser = $stmt-fetch(PDO::FETCH_ASSOC);
}else{
$aid = null;
$rowUser = null;
}
// POST
if(isset($_post['btn_save'])){
$total_attendance = strip_tags($_POST['total_attendance']);
$total_missed = strip_tags($_POST['total_missed']);
$total_escaped = strip_tags($_POST['total_escaped']);
$sid = strip_tags($_POST['sid']);
try{
if($aid != null){
if($objUser->update($total_attendance, $total_missed, $total_escaped, $sid,
$aid)){
$objUser->redirect('index.php?updated')
}
}else{
if($objUser->insert($total_attendance, $total_missed, $total_escaped, $sid)){
$objUser->redirect('index.php?inserted')
}else{
$objUser->redirect('index.php?error')
}
}
}catch(PDOException $e{
echo $e getMessge();
}
}