Parse error


#1

This is the error i am getting

Parse error: parse error, unexpected ‘{’ in C:wampwwwHTMLloggedin.php

This is the code and there is >> where it says the error is.
[php]
/ If no session is present, redirect the user.
if (!isset($_SESSION[‘username’])) {

//header ("Location:  http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/logout.php");

}
if(isset($_POST[‘submit’])) {
require_once (‘includes/mysql_connect.php’);

function escape_data ($data) {
	global $dbc;
	if (ini_get('magic_quotes_gpc')) {
		$data = stripslashes($data);
	}
	return mysql_real_escape_string($data, $dbc);
}
$message = NULL;
if (empty($_POST['comment'])) {
	$c = FALSE;
	$message .= '<p>You forgot to enter your username!</p>';
} else {
	$c = escape_data($_POST['comment']);
}
if ($c) {
$query = "INSERT INTO comment (comment, userid, datetime) VALUES ('$c', '$u', NOW())";

$result = @mysql_query ($query);

if (mysql_affected_rows() >0 {
echo ’ ', ‘The Comment was Added’, ‘’;
} else {
$message .= ‘

Please try again.

’;
}
}}
[/php]

**Mod Edit - Added PHP tags for readability!


#2

I see two opening brackets, and only one closing bracket :wink:

[php]
if (mysql_affected_rows() >0 {
[/php]

Besides that, you should always use code indenting to get a visual overview of opening-closing bracket pairs, and code blocks (it greatly improves readability). I missed one when formatting your code, and I’m pretty sure there’s more :wink:


#3

after I posted I saw that to thanks for the help