Writing/creating files with php: chmod?


#1

hi,
i have a php script that gathers some data, and then write it into a file. If the file doesnt exist, php should create one.

Works on localhost…not in the server. I assume is some chmod issue.

$filexml=//stores some xml file
$path= $fileName.".xml";
$fp = fopen($path,‘w+’);
fwrite($fp, $filexml);

any clues?

regards, goliatone


#2

allow_url_fopen is disabled in the php.ini file, so you cannot use fopen() on external URLs. For more information, see this wiki page.


Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#3

hi, tnx for the fast reply.

lets see…by external url you mean? im using relative path, and it doesnt give me any troubles with the includes i have. Fails to create/read the file, which should be located in the same directory as the php script… sorry if i dont understand your point.

regards, goliatone

Glad to help you out with any AS or flash related doubts.


#4

Anything preceeded by the protocol (like http://) is considered a remote URL, and will not work with fopen(), even if it is your own domain. Relative paths, however, should work just fine.


Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#5

Except he’s creating a file. You cannot create files through http:// or ftp:// based URLs.

To goliatone, I’d check for an error message. PHP should pop you an error message when it fails to write a file. That error should be a clue as to what’s wrong. Turn on E_ALL if you have to, make sure E_NOTICE is not excluded, too:
ini_set(“display_errors”, 1);
ini_set(“error_reporting”, E_ALL); (E_ALL includes E_NOTICE)


#6

tnx guice and scjessey for the reply.

ok, i will try to catch the php error and see whats goin on…let you know guys whats going on.

regards, goliatone

Glad to help you out with any AS or flash related doubts.


#7

hi there,
well, its not about chmod…'cose with the same script im able to create xml or txt files.

its some trouble with the format/sintaxys of the result pulled from the ddbb. it has some " in it that might cause this.

I will try with addslashes…but i dont see why im able to write the entries without using addslashes but im having trouble when pulling the entries back.

what is causing me all this trouble…im traying to store some xml format info. I really dont know how i should do it. Any clues?!

regards, goliatone

Glad to help you out with any AS or flash related doubts.