Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialFurquan Ahmad
5,148 PointsI have a parse error in my php code that i can't resolve
I keep on getting this error "Parse error: syntax error, unexpected $end in /home/u717042829/public_html/predict.php on line 114"
Here is my code, i'm trying to get the data from my phpmyadmin database and display it in a bootstrap table :
<?php
require('includes/config.php');
//if not logged in redirect to login page
if(!$user->is_logged_in()){ header('Location: login.php'); }
$id = null;
if(!empty($_GET['id']))
{
$id = $_GET['id'];
}
if($id == null)
{
header("Location: error.php");
}
else
{
// read data
//used to get id of record from query string and pass that id to database and get users information.
//if id not passed in query string then it will be redirected to โerror.phpโ page and if invalid id passed in that case it will again redirect to โindex.phpโ page.
$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT * FROM paststudent where id = ?";
$stmt = $db->prepare($sql);
$stmt->execute(array($id));
$data = $stmt->fetch(PDO::FETCH_ASSOC);
$PDO = null;
if (empty($data)){
header("Location: index.php");
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="col-sm-12">
<div class="row">
<h3>Read a User</h3>
</div>
<div class="form-group col-sm-12">
<label class="col-sm-2 control-label">First Name</label>
<div class="col-sm-10">
<p class="form-control-static"><?php echo $data['name'];?></p>
</div>
</div>
<div class="form-group col-sm-12">
<label class="col-sm-2 control-label">Last Name</label>
<div class="col-sm-10">
<p class="form-control-static"><?php echo $data['grade1'];?></p>
</div>
</div>
<div class="form-group col-sm-12">
<label class="col-sm-2 control-label">Age</label>
<div class="col-sm-10">
<p class="form-control-static"><?php echo $data['subject1'];?></p>
</div>
</div>
<div class="form-group col-sm-12">
<label class="col-sm-2 control-label">Gender</label>
<div class="col-sm-10">
<p class="form-control-static"><?php echo $data['subject2'];?></p>
</div>
</div>
<div class="form-group col-sm-12">
<a class="btn btn btn-default" href="memberspage.php">Back</a>
</div>
</div>
</div>
</body>
</html>
Furquan Ahmad
5,148 Pointsit's the last line of the code
Christian Andersson
8,712 PointsChristian Andersson
8,712 PointsWhich line is 114?