PHP Fwrite Text File Empty

Hey,

I am trying to just write data to a file. I write to the file but I cannot view it in a browser (Firefox 3.6.9). The browser shows a blank webpage and I cant see anything. If I download the the file via ftp to my hard drive it. I assume there is some problem with windows/linux translation of the file. I am using a php tutorail here http://www.tizag.com/phpT/

I am running this on 000webhost.com. I want to be able to access the test on a web browser. Usually when I specifiy a text file firefox will download it but for some reason it is just blank.

Here is my code: (Index.html)

[code]

Tizag Art Supply Order Form

Paint Brushes Erasers Quantity: [/code]

(process.php)
[php]

<?php $quantity = $_POST['quantity']; $item = $_POST['item']; $myFile = "data.txt"; $fh = fopen($myFile, 'at') or die("can't open file"); $stringData = "Bobby Bopper"; fwrite($fh, $stringData); $stringData = "Tracy Tanner"; fwrite($fh, $stringData); fclose($fh); echo "You ordered ". $quantity . " " . $item . ".
"; echo "Thank you for ordering from Tizag Art Supplies!"; ?> [/php]

Hi there,

For starters try changing fopen($myFile, 'at') to fopen($myFile, 'a')

(change the mode from β€˜at’ to β€˜a’)

Sponsor our Newsletter | Privacy Policy | Terms of Service