I just started using PHP. I am most fond of using script which create files on the server which can later be used to create pages, sending emails etc. etc. I have a free hosting account at F2S for this purpose. The problem is that the scripts do create new files when I set the folders attributes to 777, but the files cannot later be modified, written to or changed permissions. Why is that? Here's an example code from a script called PHP Rate:
if(file_exists($ficdest)) {
$compteur=fopen($ficdest, "r");
$old_stats=file($ficdest);
$stats=explode("|", $old_stats[0]);
fclose($compteur);
$new_count=$stats[0];
if ($stats[3] != $REMOTE_ADDR) {
$new_count +=1;
}
$ip_hit=$REMOTE_ADDR;
$compteur=fopen($ficdest, "w");
fputs($compteur, "$new_count|$stats[1]|$stats[2]|$ip_hit|$stats[4]");
fclose($compteur);
}
else {
$nouveau_compteur=fopen($ficdest, "w");
fputs($nouveau_compteur, "1|||$REMOTE_ADDR|");
fclose($nouveau_compteur);
Now as you can see, the script modifies the file if it exists or creates it if it is not there. Although the script does good on my local computer apache server, but when uploaded and used on F2S's server it doesn't do anything, and files are just like they are unusable!
Why is this so? Where can I find more information on writing (esp. creating) files with php, and chmoding them? Is there a free downloadable php book? (The manual sucks!) What should I do?
Haydur.