Jump to content


Photo

writing to a txt file


  • Please log in to reply
3 replies to this topic

#1 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 15 June 2006 - 05:49 AM

i need help desperately
I need a way where i can have a user type information into a form and submit it
after it is submited it should be saved to the server and ready to see
writing to a txt file
can someone help

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 15 June 2006 - 09:41 AM

Have a look at file_put_contents.

If you do not have php 5 then you will need to use

fopen
fwrite
fclose
follow me on twitter @PHPsycho

#3 Uglytroll

Uglytroll
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 18 June 2006 - 09:03 PM

I am having probs with Fopen as well.
Recieving this error when attempting to write to textfile

PHP Warning: fopen(TS345.txt) [function.fopen]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\index.php on line 135 PHP Warning: fputs(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\index.php on line 235 PHP Warning: fclose(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\index.php on line 137 PHP Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for the_only_uglytroll@shaw.ca in c:\Inetpub\wwwroot\index.php on line 170
<img src="http://i31.photobuck...troll_001.gif">
Wisdom tells me I am nothing,
Love tells me I am everything,
and between the two my blood flows.<br><br>

#4 Shaon

Shaon
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 18 June 2006 - 10:24 PM

[!--quoteo(post=384082:date=Jun 15 2006, 12:49 AM:name=perezf)--][div class=\'quotetop\']QUOTE(perezf @ Jun 15 2006, 12:49 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
i need help desperately
I need a way where i can have a user type information into a form and submit it
after it is submited it should be saved to the server and ready to see
writing to a txt file
can someone help
[/quote]

Hi,
Try with this
function savefile($filename,$content)
{
    if (!$handle = fopen($filename, 'w')) {
         echo "Cannot open file ($filename)";
         exit;
    }

    if (fwrite($handle, $content) === FALSE) {
        echo "Cannot write to file ($filename)";
        exit;
    }


    fclose($handle);
    return true;
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users