blufish Posted May 18, 2008 Share Posted May 18, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/106152-text-file-writing-error/ Share on other sites More sharing options...
MadTechie Posted May 18, 2008 Share Posted May 18, 2008 instead of using the http path use the file path ie $file = fopen(msgz.txt","r+"); or $file = fopen(dirname(__FILE__)."/msgz.txt","r+"); Quote Link to comment https://forums.phpfreaks.com/topic/106152-text-file-writing-error/#findComment-544088 Share on other sites More sharing options...
blufish Posted May 18, 2008 Author Share Posted May 18, 2008 thanks madtechie, could anyone tell me why it returns 0 it should be writing what was entered in a form is there some other sort of thing I should use. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/106152-text-file-writing-error/#findComment-544091 Share on other sites More sharing options...
MadTechie Posted May 18, 2008 Share Posted May 18, 2008 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); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/106152-text-file-writing-error/#findComment-544096 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.