brbsta wrote:Wp, i don't see that, i though I defined it first. The im defining $newfile in the switch statement then in fwrite im using the $fp which opens the new file. Even if that didnt work this script:
Is opening new file after it is defined and im still getting the same errors.
I think you problem is with your fopen() script... your resouce mode does not make any sense... what I mean by that is the "ab" you have in your fopen fuction - fopen($newfile, ab) check the php manual and you can only use:
'r' Open for reading only; place the file pointer at the beginning of the file.
'r+' Open for reading and writing; place the file pointer at the beginning of the file.
'w' Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'w+' Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'a' Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'a+' Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'x' Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. This option is supported in PHP 4.3.2 and later, and only works for local files.
'x+' Create and open for reading and writing; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call.
so i think if you change your fopen($newfile, ab) to $fp = fopen($newfile, "a+). Which the a+ means if file does not exist create it. It might work. But I see several mistakes in your code.. Lets take a look at the end of the code, lets start at your file open script...
I would do this..
//I would set $fp = fopen($newfile, "a+");
fopen($newfile, ab); //this is your code.
//Then I would set fwrite($fp, $content);
fwrite( $fp, $content ); //this is your code
//The is would close the file fclose($fp);
fclose($newfile); //this is your code
do you see your mistakes
echo "All done!";