3dmacguy
08-03-2004, 04:41 AM
Hi,
I am passing a variable successfully from Flash to a php script. The php script, I believe, is fine. The PHP script accepts the variable and attempts to open, write, and then close an XML file.
<?php
$data = $HTTP_POST_VARS["news"] . "\r\n";
$filename = "newsxml.xml";
//Imports old data
$handle = @fopen($filename, "r");
$old_content = fread($handle, filesize ($filename));
fclose($handle);
//Sets up new data
$final_content = $data.$old_content;
//Writes new data
$handle2 = fopen($filename, "w");
$finalwrite = fwrite($handle2, $final_content);
fclose($handle2);
?>
When I try to pass the variable to the PHP page, though, I get this error message....
Warning: fopen(newsxml.xml): failed to open stream: Permission denied in /Library/WebServer/Documents/josh/writexml.php on line 11
Warning: fwrite(): supplied argument is not a valid stream resource in /Library/WebServer/Documents/josh/writexml.php on line 11
Warning: fclose(): supplied argument is not a valid stream resource in /Library/WebServer/Documents/josh/writexml.php on line 11
I know the variable is being passed as it echos back fine. But it seems there are some permissions errors. I am completely new to using PHP and setting permissions. I am running Mac OS X 10.3 and am using the default configuration of Apache w/ the PHP module supplied from Apple. Serving from 'Library/WebServer/Documents/myFolder'. Any idea why I cannot fopen, fread, or fclose a file?
Thanks. Been stuck on this all day.
-Josh
I am passing a variable successfully from Flash to a php script. The php script, I believe, is fine. The PHP script accepts the variable and attempts to open, write, and then close an XML file.
<?php
$data = $HTTP_POST_VARS["news"] . "\r\n";
$filename = "newsxml.xml";
//Imports old data
$handle = @fopen($filename, "r");
$old_content = fread($handle, filesize ($filename));
fclose($handle);
//Sets up new data
$final_content = $data.$old_content;
//Writes new data
$handle2 = fopen($filename, "w");
$finalwrite = fwrite($handle2, $final_content);
fclose($handle2);
?>
When I try to pass the variable to the PHP page, though, I get this error message....
Warning: fopen(newsxml.xml): failed to open stream: Permission denied in /Library/WebServer/Documents/josh/writexml.php on line 11
Warning: fwrite(): supplied argument is not a valid stream resource in /Library/WebServer/Documents/josh/writexml.php on line 11
Warning: fclose(): supplied argument is not a valid stream resource in /Library/WebServer/Documents/josh/writexml.php on line 11
I know the variable is being passed as it echos back fine. But it seems there are some permissions errors. I am completely new to using PHP and setting permissions. I am running Mac OS X 10.3 and am using the default configuration of Apache w/ the PHP module supplied from Apple. Serving from 'Library/WebServer/Documents/myFolder'. Any idea why I cannot fopen, fread, or fclose a file?
Thanks. Been stuck on this all day.
-Josh