• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

[php] unexpected T_VARABLE

wickedgenius

New Member
I get the following error with the code below:

Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\Aurillian.co.uk\forum\replytopost.php on line 49

Can somebody help me please?

Code:
Code:
<?php
/*
TOPIC REPLY SCRIPT

	File best viewed using a basic text editor (Notepad for 

example).

	Coded in PHP4.

	Adds post to database with specified topic id.

	Do not edit unless you know what you are doing.

	File Log:
		+Wickedgenius
			First created file
			16/10/2007 16:10
		+Wickedgenius
			Added Support for db_info.php
			16/10/2007 16:30
*/

//Include database info
include("db_info.php");

//Connect to mysql
mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());

//Check to see if showing form or adding to database
if (!$_POST) {
	//showing form; check for topic id in web address
	if (!isset($_GET["post_id"])) {
		header("Location: topiclist.php");
		exit;
	}

	//Verify topic and post
	$verify = "SELECT ft.topic_id, ft.topic_title FROM forum_posts 

AS fp LEFT JOIN forum_topics AS ft ON fp.topic_id = ft.topic_id WHERE 

fp.post_id = '".$_GET["post_id"]."'";
	$verify_res = mysql_error($verify) or die(mysql_error());

	if (mysql_num_rows($verify_res) < 1) {
		//Post or topic doesn't exist
		header("Location: topiclist.php");
		exit;
	} else {
		//Get topic id and title
		while ($topic_info = mysql_fetch_array($verify_res)) {
			$topic_id = $topic_info['topic_id']
			$topic_title = stripslashes($topic_info

['topic_title']);
		}

	echo "
		<html>
		<head>
		<title>Forum: Post in ".$topic_title."</title>
		</head>
		<body>
		<h1>Post Your Reply in $topic_title</h1>
		<form method=\"post\" action=\"".$_SERVER

["PHP_SELF"]."\">
		<p><strong>Your E-Mail Address:</strong><br />
		<input type=\"text\" name=\"post_owner\" size=\"40\" 

maxlength=\"150\"></p>
		<p><strong>Post Text:</strong><br />
		<textarea name=\"post_text\" rows=\"8\" cols=\"40\" 

wrap=\"virtual\"></textarea></p>
		<input type=\"hidden\" name=\"topic_id\" 

value=\"$topic_id\">
		<p><input type=\"submit\" name=\"submit\" value=\"Add 

Post\"></p>
		</form>
		</body>
		</html>";
	}

} else if ($_POST) {
	//Check for required fields from form
	if ((!$_POST["topic_id"]) || (!$_POST["post_text"]) || (!

$_POsT["post_owner"])) {
		header("Location: topiclist.php");
		exit;
	}

	//Add post info to database
	$add_post = "INSERT INTO forum_posts (topic_id, post_text, 

post_create_time, post_owner) VALUES ('".$_POST["topic_id"]."', 

'".$_POST["post_text"]."', now(), '".$_POST["post_owner"]."')";
	$add_post_res = mysql_query($add_post) or die(mysql_error());

	//redirect user to topic
	header("Location: showtopic.php?topic_id=".$_POST

["topic_id"]);
	exit;
}

?>
 
You forgot to add ); on the end of your striplashes.
PHP:
<?php
/*
TOPIC REPLY SCRIPT

	File best viewed using a basic text editor (Notepad for 

example).

	Coded in PHP4.

	Adds post to database with specified topic id.

	Do not edit unless you know what you are doing.

	File Log:
		+Wickedgenius
			First created file
			16/10/2007 16:10
		+Wickedgenius
			Added Support for db_info.php
			16/10/2007 16:30
*/

//Include database info
include("db_info.php");

//Connect to mysql
mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());

//Check to see if showing form or adding to database
if (!$_POST) {
	//showing form; check for topic id in web address
	if (!isset($_GET["post_id"])) {
		header("Location: topiclist.php");
		exit;
	}

	//Verify topic and post
	$verify = "SELECT ft.topic_id, ft.topic_title FROM forum_posts 

AS fp LEFT JOIN forum_topics AS ft ON fp.topic_id = ft.topic_id WHERE 

fp.post_id = '".$_GET["post_id"]."'";
	$verify_res = mysql_error($verify) or die(mysql_error());

	if (mysql_num_rows($verify_res) < 1) {
		//Post or topic doesn't exist
		header("Location: topiclist.php");
		exit;
	} else {
		//Get topic id and title
		while ($topic_info = mysql_fetch_array($verify_res)) {
			$topic_id = $topic_info['topic_id']
			$topic_title = stripslashes($topic_info);

['topic_title']);
		}

	echo "
		<html>
		<head>
		<title>Forum: Post in ".$topic_title."</title>
		</head>
		<body>
		<h1>Post Your Reply in $topic_title</h1>
		<form method=\"post\" action=\"".$_SERVER

["PHP_SELF"]."\">
		<p><strong>Your E-Mail Address:</strong><br />
		<input type=\"text\" name=\"post_owner\" size=\"40\" 

maxlength=\"150\"></p>
		<p><strong>Post Text:</strong><br />
		<textarea name=\"post_text\" rows=\"8\" cols=\"40\" 

wrap=\"virtual\"></textarea></p>
		<input type=\"hidden\" name=\"topic_id\" 

value=\"$topic_id\">
		<p><input type=\"submit\" name=\"submit\" value=\"Add 

Post\"></p>
		</form>
		</body>
		</html>";
	}

} else if ($_POST) {
	//Check for required fields from form
	if ((!$_POST["topic_id"]) || (!$_POST["post_text"]) || (!

$_POsT["post_owner"])) {
		header("Location: topiclist.php");
		exit;
	}

	//Add post info to database
	$add_post = "INSERT INTO forum_posts (topic_id, post_text, 

post_create_time, post_owner) VALUES ('".$_POST["topic_id"]."', 

'".$_POST["post_text"]."', now(), '".$_POST["post_owner"]."')";
	$add_post_res = mysql_query($add_post) or die(mysql_error());

	//redirect user to topic
	header("Location: showtopic.php?topic_id=".$_POST

["topic_id"]);
	exit;
}

?>
 
also forgot another ;

PHP:
        //Get topic id and title
        while ($topic_info = mysql_fetch_array($verify_res)) {
            $topic_id = $topic_info['topic_id'];
            $topic_title = stripslashes($topic_info);
 
Most ide's have an auto correct function, one that you can customize for mistakes that you or your input devices make ... I'd do that ...
 
Back
Top