I am having a nightmare with something I thought was working. Novice to PDO. I have a single page form that picks up details from a MYSQL database and allows the user to edit. So I know the connection to the database is OK.
On clicking the submit button it runs another php page to update the record. At which point it goes wrong.
$id = htmlspecialchars($_POST['id']);
$book_year = htmlspecialchars($_POST['book_year']);
$chapter = htmlspecialchars($_POST['chapter']);
$para = htmlspecialchars($_POST['para']);
$title = htmlspecialchars($_POST['title']);
$summary = htmlspecialchars($_POST['summary']);
$seen_date = htmlspecialchars($_POST['seen_date']);
$pdo = new PDO($dsn, $user, $pass, $options);
$data = [
'id' => $id,
'book_year' => $book_year,
'chapter' => $chapter,
'para' => $para,
'title' => $title,
'summary' => $summary,
'seen_date' => $seen_date,
];
// issue is in next 4 lines
$sql = "UPDATE update_tbl SET book_year=:book_year, chapter=:chapter, para=:para, title :title,
summary=:summary, seen_date=:seen_date WHERE id=:id";
$stmt= $pdo->prepare($sql);
$stmt->execute($data);
It seems to be something in those last 4 lines it isn’t happy with. I’m rapidly losing the will to live so hoping someone can help out. Thanks