Hi all, in my code i try to connect to a database and retrieve a list of students. These students have a link, and if i click on one of those links, i will get additional information of a single student. The code is like this:
[php]
Studentregister
<?phprequire_once (‘auth.php’);
require_once (‘student.class.php’);
//vis en enkelt post
if (isset($_GET[‘id’])) {
$id = (int)$_GET[‘id’];
$stmt = $dbh->prepare(“SELECT * FROM studenter WHERE id= :id”);
$stmt->bindParam(’:id’, $id);
$stmt->execute();
if ($student = $stmt->fetch()) {
print("Navn: " . $student['etternavn'] . "<br />\n");
print("Klasse: " . $student['klasse'] . "<br />\n");
print("Mobil: " . $student['mobil'] . "<br />\n")
}
else {
echo "Beklager, fant ingen poster!";
}
}
else {
while ($student = $stmt->fetch() {
print("<a href=" . $_SERVER[‘PHP_SELF’] . “?id=” . $student->hentId() . “>”. $student->hentNavn() . “
\n”);
}
}
?>
I am able to access the database, but i get a silly error no matter what i do:
Parse error: syntax error, unexpected ‘}’ in C:\xampp\htdocs\Lab4\db2_endret.php on line 23
Obviously a block is missing or shouldn’t be somewhere, but i cannot understand where. Are there anyone here who can point me in the right direction?