<?php
include('db.php');
include('cLogin.php');
$username = "";
$isFollowing = False;
if (isset($_GET['username'])) {
if (DB::query('SELECT u FROM users WHERE u=:username', array(':username'=>$_GET['username']))) {
$username = DB::query('SELECT u FROM users WHERE u=:username', array(':username'=>$_GET['username']))[0]['u'];
if (isset($_POST['follow'])) {
if ($userid != $followerid) {
if (!DB::query('SELECT follower_id FROM followers WHERE user_id=:userid', array(':userid'=>$userid))) {
DB::query('INSERT INTO followers VALUES (\'\', :userid, :followerid)', array(':userid'=>$userid, ':followerid'=>$followerid));
} else {
echo 'Already following!';
}
$userid = DB::query('SELECT id FROM users WHERE u=:username', array(':username'=>$_GET['username']))[0]['id'];
$followerid = Login::isLoggedIn();
if (!DB::query('SELECT follower_id FROM followers WHERE user_id=:userid', array(':userid'=>$userid))) {
DB::query('INSERT INTO followers VALUES (\'\', :userid, :followerid)', array(':userid'=>$userid, ':followerid'=>$followerid));
} else {
#echo 'Already following!';
$isFollowing = True;
}
$userid = DB::query('SELECT id FROM users WHERE u=:username', array(':username'=>$_GET['username']))[0]['id'];
$followerid = Login::isLoggedIn();
$isFollowing = True;
}
if (isset($_POST['unfollow'])) {
if ($userid != $followerid) {
if (DB::query('SELECT follower_id FROM followers WHERE user_id=:userid', array(':userid'=>$userid))) {
DB::query('DELETE FROM followers WHERE user_id=:userid AND follower_id=:followerid', array(':userid'=>$userid, ':followerid'=>$followerid));
}
$isFollowing = False;
}
}
} else {
die('User not found!');
}
}
?>
<title>Gamerfile of <?php echo $username; ?> // GamersCafe</title>
<h1><?php echo $username; ?>'s GamerFile</h1>
<form action="profile.php?username=<?php echo $username; ?>" method="post">
<?php
if ($userid != $followerid) {
if ($isFollowing) {
echo '<input type="submit" name="unfollow" value="Unfollow">';
} else {
echo '<input type="submit" name="follow" value="Follow">';
}
}
?>
</form>
I was coding a social network profile page the other day (the code is above), and I got this error: Parse error: syntax error, unexpected end of file in C:\xamppp\htdocs\gamerscafe\profile.php on line 57 What did I do wrong? I checked some other questions, and they apparently used short open tags, but as you can see, I didn't, so that's weird.
EDIT: I don't know what I forgot in the file, so if somebody can figure out what's wrong, that would be helpful. Thanks!
EDIT 2: I fixed it by putting in a curly bracket!