PDA

View Full Version : need code fixd



chris
03-06-2008, 11:12 AM
error:
Parse error: syntax error, unexpected T_VARIABLE in /usr/www/virtual/jupzchris/www.jupzchris.com/email.php on line 10



<HTML>
<HEAD><TITLE></TITLE></HEAD>
<BODY>
<?
if ($_POST['data'] != "") {
$filedata=@explode(",",@file_get_contents("file.txt"));
if ($filedata != "") {
if (array_search($_POST['data'],$filedata) == FALSE) {
$filedata[]=$_POST['data'];
file_put_contents("file.txt",implode(","$filedata));
echo "<h2>data added to file</h2><br /><br />";
} else {
echo "<h2>data already exists in file</h2><br /><br />";
}
} else {
$filedata=array();
$filedata[]=$_POST['data'];
file_put_contents("file.txt",implode(","$filedata));
echo "<h2>data added to file</h2><br /><br />";
}
}


?>

<FORM method="post" action="<? echo($_SERVER['PHP_SELF']); ?>">
<input type="text" size="30" maxlength="255" name="data">
</FORM>
</BODY>
</HTML>

Vershun
03-06-2008, 11:14 AM
Syntax looks OK, what PHP version?

Run <?php phpinfo(); ?> in a .php file if you don't know.

Napolean
03-06-2008, 11:16 AM
<HTML>
<HEAD><TITLE></TITLE></HEAD>
<BODY>
<?
if ($_POST['data'] != "") {
<A href="mailto:$filedata=@explode(",",@file_get_contents("file.txt">$filedata=@explode(",",@file_get_contents("file.txt"));
if ($filedata != "") {
if (array_search($_POST['data'],$filedata) == FALSE) {
$filedata[]=$_POST['data'];
file_put_contents("file.txt",implode(",",$filedata));
echo "<h2>data added to file</h2><br /><br />";
} else {
echo "<h2>data already exists in file</h2><br /><br />";
}
} else {
$filedata=array();
$filedata[]=$_POST['data'];
file_put_contents("file.txt",implode(",",$filedata));
echo "<h2>data added to file</h2><br /><br />";
}
}

?>
<FORM method="post" action="<? echo($_SERVER['PHP_SELF']); ?>">
<input type="text" size="30" maxlength="255" name="data">
</FORM>
</BODY>
</HTML>


you forgot a comma on line 10 in the implode function