View Single Post
Old 03-06-2008, 10:38 AM  
Nookster
Confirmed IT Professional
 
Industry Role:
Join Date: Nov 2005
Location: Hollywood, CA
Posts: 3,744
Quote:
Originally Posted by Chris View Post
i already have one code but it doesnt work on my server

Code:
<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>
spits out Parse error: syntax error, unexpected T_VARIABLE in /usr/www/virtual/jupzchris/www.jupzchris.com/email.php on line 10
Change line 10, that reads:
file_put_contents("file.txt",implode(","$filedata) );
change it to:
file_put_contents("file.txt",implode(",",$filedata ));

You're welcome.
Nookster is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote