Jump to content

Text file writing error


blufish

Recommended Posts

Ok, so I'm trying to make a simple shoutbox, heres my code, my errors and my hosting specs.

 

<?php
$file = fopen("http://www.frozenoven.com/boxz/msgz.txt","r+");
$lateer = fgets($file);
$mypost = ($_POST['mesg'] + $latter);
fclose($file);
$filet = fopen("http://www.frozenoven.com/boxz/msgz.txt","w+");
fwrite ($filet,$mypost);
fclose($file);
?>

 

Here are the numerous errors:

 

Warning: fopen(http://www.frozenoven.com/boxz/msgz.txt) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/blufish/public_html/boxz/postingisbad.php on line 2

 

Warning: fgets(): supplied argument is not a valid stream resource in /home/blufish/public_html/boxz/postingisbad.php on line 3

 

Warning: fclose(): supplied argument is not a valid stream resource in /home/blufish/public_html/boxz/postingisbad.php on line 5

 

Warning: fopen(http://www.frozenoven.com/boxz/msgz.txt) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/blufish/public_html/boxz/postingisbad.php on line 6

 

Warning: fwrite(): supplied argument is not a valid stream resource in /home/blufish/public_html/boxz/postingisbad.php on line 7

 

Warning: fclose(): supplied argument is not a valid stream resource in /home/blufish/public_html/boxz/postingisbad.php on line 8

 

Here are my hosting specs:

bandwidth:

6,000,000mb

6,000gb

space:

600,000mb

600gb

 

If you need to check more of my specs:

 

http://www.hostgator.com/shared.shtml

(I'm using the baby hosting)

 

does anyone here know how to make it so I can write the file or anything I am doing wrong.  Thanks in advance.  :)

Link to comment
https://forums.phpfreaks.com/topic/106152-text-file-writing-error/
Share on other sites

Try these 2 examples

<?php
$data = file_get_contents("msgz.txt");
if(!empty($_POST['mesg']))
{
$data = $data.$_POST['mesg'];
file_put_contents("msgz.txt", $data);
}
?>

 

or

this uses less memory

<?php
if(!empty($_POST['mesg']))
{
$fp = fopen('msgz.txt', 'a'); //Appends Data
fwrite($fp, $_POST['mesg']);
fclose($fp);
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.