Hi all,
I can't see whats wrong with this code, but I still got this error:
Parse error: parse error, unexpected T_VARIABLE in /home/xxsqnea/public_html/news/addnews.php on line 26
<?
$ip = getenv('REMOTE_ADDR');
$date = date('j M y');
if(isset($_GET['commented']))
{
// Tell the user it has been submitted (optional)
echo('Your comment has been posted.');
// Set Mysql Variables
$host = 'localhost';
$user = 'myusername';
$pass = 'mypassword';
$db = 'mydatabase';
$table = 'a table in my database';
// Set global variables to easier names
$author = $_GET['author'];
$message = $_GET['message'];
$title = $_GET['title'];
// Connect to Mysql, select the correct database, and run teh query which adds the data gathered from the form into the database
mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
$add_all = 'INSERT INTO $table values('$author','$message','$ip','$date','$title')';
mysql_query($add_all) or die(mysql_error());
}
else
{
// If the form has not been submitted, display it!
?>
<form method='get' action='<? echo'$PHP_SELF'; ?>'>
Name : <input type='text' name='author'><br><br>
Title : <input type='text' name='title'><br><br>
Message : <input type='text' name='message'><br><br>
<input type='hidden' name='commented' value='set'>
<input type='submit' value='Post your comment'>
</form>
<?
}
?>
Any help would be appreciated.