Hey everyone, well I don't much understand why, but I'm getting the below error:
Parse error: syntax error, unexpected '}' in /home/adam/public_html/development/content/index.php on line 139
The file that I am using (not all the way complete, but should work so far):
index.php
<?
require('config.php');
error_reporting(E_ALL);
class content {
function dispLinks($type){
$query = sprintf("SELECT link, id, name, time FROM ".$type." ORDER BY time DESC");
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
echo '<center><a href="index.php?id='.$row['id'].'&&type='.$type.'">'.$row['name'].'</a></center>';
}
mysql_free_result($result);
}
}
////
function formLogin(){
echo '<center><a href="index.php?go=home">Home</a><br /><br /><br />'
. '<center><form action="index.php" method="POST">'
. '<b>Username:</b><br />'
. '<input type="text" name="username" /><br /><br />'
. '<b>Password:</b><br />'
. '<input type="password" name="password" /><br /><br />'
. '<b>Code:</b><br />'
. '<input type="text" name="code" /><br />'
. '<input type="submit" name="submitLogin" value="Login" />'
. '</form></center>';
}
////
function processLogin() {
if ($_POST['username'] == "Vladimir"
&& $_POST['password'] == "David1881"
&& $_POST['code'] == "z8cu") {
$this->panel();
}
}
////
function panel() {
echo '<center><b>Select an Option:</b><br /><br />'
. '<a href="index.php?panel_op=viewGame">View the games in the Database</a><br />'
. '<a href="index.php?panel_op=deleteGame_form">Delete a game from the Database</a><br />'
. '<a href="index.php?panel_op=addGame_form">Add a Game to the Database</a><br />';
}
////
function add($type) {
mysql_query("INSERT INTO ".$type." (name, link, time) VALUES ('".$_POST['name']."', '".$_POST['link']."', '".date("l, F jS, Y \a\t\ g:i:s A")."')");
if (mysql_error() !== "") {
echo '<center><a href="index.php?go=home">Home</a><br /><br /><br />'
. '<center><b>Error:</b>'.mysql_error().'</center>';
} else {
echo '<center><a href="index.php?go=home">Home</a><br /><br /><br />'
. '<center><b>The '.$type.' </b>'.$_POST['name'].'<b> was added successfully.';
}
}
////
function delete($type) {
mysql_query("DELETE from ".$type." WHERE id='".$_POST['id']."'");
if (mysql_error() !== "") {
echo '<center><a href="index.php?go=home">Home</a><br /><br /><br />'
. '<center><b>Error:</b>'.mysql_error().'</center>';
} else {
echo '<center><a href="index.php?go=home">Home</a><br /><br /><br />'
. '<center><b>The '.$type.' </b>'.$_POST['name'].'<b> was deleted successfully.';
}
////
function view($type) {
echo '<center><a href="index.php?go=home">Home</a><br /><br /><br />'
. '<center><font color="blue"><b>List of '.$type.'s:</b></font><br /><br />'
. '<table align="center">'
. '<tr><td><center><b>Name:</b></cemter></td>'
. '<td><center><b>Link:</b></center></td>'
. '<td><center><b>ID:</b></center></td>'
. '<td><center><b>Submit Date:</b></center></td></tr>';
$query = sprintf("SELECT link, id, name, time FROM games ORDER BY time DESC");
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
echo '<tr><td>'.$row['name'].'</td>'
. '<td>'.$row['link'].'</td>'
. '<td>'.$row['id'].'</td>'
. '<td>'.$row['time'].'</td></tr>';
}
mysql_free_result($result);
}
}
////
function formAdd($type) {
echo '<center><a href="index.php?go=home">Home</a><br /><br /><br />'
. '<center><b><font color="blue">Please fill out the below information:</font></b>'
. '<br /><br/>'
. '<form action="index.php" method="POST">'
. '<b>Name:</b><br />'
. '<input type="text" name="name" /><br /><br />'
. '<b>Link:</b><br />'
. '<input type="text" name="link" /><br />'
. '<input type="hidden" name="type" value="'.$type.'" />'
. '<input type="submit" name="submitAdd" value="Add '.$type.'" />'
. '</form></center>';
}
////
function formDelete($type) {
echo '<center><a href="index.php?go=home">Home</a><br /><br /><br />'
. '<center><b><font color="blue">Please fill out the below information:</font></b>'
. '<br /><br/>'
. '<form action="index.php" method="POST">'
. '<input type="text" name="id" /><br />'
. '<input type="hidden" name="type" value="'.$type.'" />'
. '<input type="submit" name="submitDelete" value="Delete '.$type.'" />'
. '</form></center>';
}
function disp($type, $id) {
$query = sprintf("SELECT link, id, name FROM games WHERE id='".$id."'");
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
echo '<center><a href="index.php?go=home">Home</a><br /><br /><br />'
. '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0">'
. '<param name="'.$row['name'].'" value="'.$row['link'].'" />'
. '<param name="quality" value="high" />'
. '<embed src="'.$row['link'].'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="32" height="32">'
. '</embed></object><tr><td>';
}
mysql_free_result($result);
}
}
}
$class = new content();
if (!$_POST && !$_GET) {
echo '<center><font color="blue"><b>Select an option:</b></font>'
. '<a href="index.php?type=games">Games</a><br />'
. '<a href="index.php?type=flash">Flash</a><br />';
} else if (isset($_GET['type'])) {
$class->dispLinks($_GET['type']);
} else if (isset($_GET['id']) && isset($_GET['type'])) {
if ($_GET['type'] == "game") {
$class->disp("game", $_GET['id']);
} else if ($_GET['type'] == "flash") {
$class->disp("flash", $_GET['id']);
} else if (isset($_GET['go'])) {
if ($_GET['go'] == "home") {
echo '<center><font color="blue"><b>Select an option:</b></font>'
. '<a href="index.php?type=games">Games</a><br />'
. '<a href="index.php?type=flash">Flash</a><br />';
} else if ($_GET['go'] == "login") {
$class->formLogin();
} else {
echo '<center><b>Uknown "go" command.</b></center>';
}
} else if (isset($_POST['submitLogin'])) {
$class->processLogin();
} else if (isset($_GET['panel_op'])) {
if ($_GET['panel_op'] == "viewGame") {
$class->view("game");
} else if ($_GET['panel_op'] == "deleteGame_form") {
$class->formDelete("game");
} else if ($_GET['panel_op'] == "addGame_form") {
$class->formAdd("game");
}
} else if (isset($_POST['submitAdd'])) {
$class->add($_POST['type']);
} else if (isset($_POST['submitDelete'])) {
$class->delete($_POST['type']);
}
?>
Line 139 is a } which is being used to end the disp($type, $id) function, if I delete the bracket it says that the next bracket is unexpected too, and if I delete that one, the $class = new class(); is an unexpected T_VARIABLE because I didn't end the function or class..