Topic: PHP Help
Well, I'm writing a posting script for my blog and I'm getting some errors with this code:
<?php
include('arrays.php');
if (isset($uname)){
if ($verify[$uname] == $password)
{
include("config.php");
if($submit)
{//begin of if($submit).
// Set global variables to easier names
// and pervent sql injection and apostrophe to break the db.
$title = mysql_real_escape_string($_POST['title']);
$newstext = mysql_real_escape_string($_POST['newstext']);
//check if (title) field is empty then print error message.
if(!$title){ //this means If the title is really empty.
echo "Error: News title is a required field. Please fill it.";
exit(); //exit the script and don't do anything else.
}// end of if
//run the query which adds the data gathered from the form into the database
// this is the old query \/
//$result = mysql_query("INSERT INTO news (title, dtime, text1) VALUES ('$title',NOW(),'$text1')",$connect);
$result = mysql_query("INSERT INTO `news` (`id`, `postdate`, `title`, `newstext`) VALUES (RAND(), NOW(), ''$title'', ''$newstext'')", $connect);
//print success message.
echo "<b>Thank you! News added Successfully!<br>You'll be redirected to Home Page after (4) Seconds";
echo "<meta http-equiv=Refresh content=4;url=index.php>";
}//end of if($submit).
// If the form has not been submitted, display it!
else
{ ?>
<br>
<h3>Post News</h3>
<form method="post" action="<?php echo $PHP_SELF ?>">
Title: <input name="title" size="40" maxlength="255"><br />
Newstext: <textarea name="newstext" rows="7" cols="30"></textarea><br />
<input type="submit" name="submit" value="Add News"><input type="reset" name="reset" value="Reset News">
</form>
<?
}
?>
The error is: Parse error: parse error, unexpected $ in /home/lnorton/public_html/tiger/blog/post.php on line 40