I am getting an error in this code, simple fix i'm sure.

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

User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Are you looping through a filesystem write procedure? Seems resource intensive...

Try this in your code.

Code: Select all

<?php
// open the file or kill the script and show error
$dude = fopen($fileName, 'w') or die("can't open file");

// create what to write
$write = $_POST['name'] . $_POST['email'] . $_POST['article'];

// Write to the file with fwrite now
$numBytes = fwrite($dude, $write);

// For some reason, write again, but without all the parameters
// This assumes that you are in a loop and that you have a 
// series of files named article{somenumber}.txt
fwrite("article/article" . [$i] . ".txt");

// Close the file handle
fclose($dude);
?> 
Post Reply