Hi,
I finally figured out what I was doing wrong. I was trying update the id instead of using it to tell the mysql which row to update.
My index.php file is now,
try
{
$sql = 'UPDATE teachingpts SET
unit = :unit,
year = :year,
exam = :exam,
question = :question,
part = :part,
subpart = :subpart,
currno = :currno,
topic = :topic,
subtopic = :subtopic,
tp = :tp,
questiontype = :questiontype
WHERE id = :id';
$s = $pdo->prepare($sql);
$s->bindParam(':id', $_POST['id']);
$s->bindParam(':unit', $_POST['unit']);
$s->bindParam(':year', $_POST['year']);
$s->bindParam(':exam', $_POST['exam']);
$s->bindParam(':question', $_POST['question']);
$s->bindParam(':part', $_POST['part']);
$s->bindParam(':subpart', $_POST['subpart']);
$s->bindParam(':currno', $_POST['currno']);
$s->bindParam(':topic', $_POST['topic']);
$s->bindParam(':subtopic', $_POST['subtopic']);
$s->bindParam(':tp', $_POST['tp']);
$s->bindParam(':questiontype', $_POST['questiontype']);
$s->execute();
}
catch (PDOException $e)
{
$error = 'Error updating submitted teaching points....';
include 'error.html.php';
echo $e;
exit();
}
Previously and incorrectly it was like this,
try
{
$sql = 'UPDATE teachingpts SET
id =: id, ------ this is incorrect
unit = :unit,
year = :year,
exam = :exam,
question = :question,
part = :part,
subpart = :subpart,
currno = :currno,
topic = :topic,
subtopic = :subtopic,
tp = :tp,
questiontype = :questiontype'; ----needs WHERE id = :id';
$s = $pdo->prepare($sql);
$s->bindParam(':id', $_POST['id']);
$s->bindParam(':unit', $_POST['unit']);
$s->bindParam(':year', $_POST['year']);
$s->bindParam(':exam', $_POST['exam']);
$s->bindParam(':question', $_POST['question']);
$s->bindParam(':part', $_POST['part']);
$s->bindParam(':subpart', $_POST['subpart']);
$s->bindParam(':currno', $_POST['currno']);
$s->bindParam(':topic', $_POST['topic']);
$s->bindParam(':subtopic', $_POST['subtopic']);
$s->bindParam(':tp', $_POST['tp']);
$s->bindParam(':questiontype', $_POST['questiontype']);
$s->execute();
}
catch (PDOException $e)
{
$error = 'Error updating submitted teaching points....';
include 'error.html.php';
echo $e;
exit();
}
Thanks,
Shane