Page 1 of 1

Why does this show an error after the second if statement?

Posted: Fri Jun 25, 2004 4:35 pm
by andylyon87

Code: Select all

if($save){
if($TheFile="form_data/$_POSTїsave].txt";
         $Open = fopen($TheFile,"w");
         if($Open){
                   fwrite($Open,"$editing\n");
                   fclose($Open);
                   $Worked=True;
          }else{
          $Worked=False;
          }
          return $Worked;
          ){
print("<TR><TD colspan=5><CENTER>file created/updated");
&#125;else&#123;
print("<TR><TD colspan=5><CENTER>Error occured during processing please go back and retry");&#125;
&#125;
the second if statement is not accepted?
I had a workin version but have lost it so need this one to work.
Have made the write to file a separate functon but its to do with the line $TheFile. Please help
thanks
Andy :?

Posted: Fri Jun 25, 2004 4:58 pm
by markl999
Yeah, that's pretty borked, i think you want something along the lines of:

Code: Select all

<?php
if(!empty($_POST['save'])){
  $TheFile = 'form_data/'.$_POST['save'].'.txt';
  $Open = @fopen($TheFile, 'w');
  if($Open === FALSE){
    $msg = 'Error occured during processing please go back and retry.';
  } else {
    fputs($Open, $editing."\n");
    fclose($Open);
    $msg = 'file created/updated.';
  }
  echo '<tr><td colspan="5" align"center">'.$msg.'</td></tr>';
}
?>

Posted: Sat Jun 26, 2004 10:39 am
by andylyon87
so does the !empty correspond to not empty

Posted: Sat Jun 26, 2004 10:56 am
by andylyon87
cheers mate works now