problems writing to file (not naming the file correctly)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
andylyon87
Forum Contributor
Posts: 168
Joined: Sat Jan 31, 2004 5:31 am
Location: Dundee

problems writing to file (not naming the file correctly)

Post by andylyon87 »

This code doesn't seem to be working, it writes to the file but doesn't name the file as speified by the user from $save, it names the fill as a blank, but it works if I put time() in its place:

Code: Select all

if($save){
writetofile("$editing\n");
print("<TR><TD colspan=5><CENTER>file created/updated");
&#125;
function writetofile($editing)&#123;
$TheFile = "form_data/$save.txt";
         $Open = fopen ($TheFile,"w");
         if($Open)&#123;
                   fwrite ($Open,"$editing\n");
                   fclose($Open);
                   $Worked=True;
         &#125; else &#123;
           $Worked = False;
          &#125;
          return $Worked;
          &#125;
below is the code for the reference:

Code: Select all

<TR><TD colspan=5>Save As:<input type=text name="save" size=20>
Anyone who can help I would be very greatful
doeboy
Forum Newbie
Posts: 10
Joined: Sun Mar 21, 2004 10:18 am

Post by doeboy »

Have you tried $_POST['save'] or $_GET?
andylyon87
Forum Contributor
Posts: 168
Joined: Sat Jan 31, 2004 5:31 am
Location: Dundee

Post by andylyon87 »

thank you very very much
Post Reply