You are writing too much code. PHP just chokes with amount and can't process further
if(isset($_GET['id'])) {
$stmt = $db->prepare('SELECT * FROM projects WHERE slug = ?');
$stmt->execute(array($_GET['id']));
$projects = $stmt->fetchAll();
if ($projects) {
$smarty->assign('projects',$projects);
} else {
header("Location: /projects.php");
exit();
}
}
is all the code you need