ag3nt42 Posted June 10, 2008 Share Posted June 10, 2008 Hi all, I'm trying to use this function and I can't seem to get it to work.. file_put_contents() here is my code: $Cinfo ="This bites"; echo file_put_contents("Cinfo.php",$Cinfo,FILE_APPEND); everytime i try and use it i'm getting this error Warning: file_put_contents(Cinfo.php) [function.file-put-contents]: failed to open stream: Permission denied I have the permissions set to 7777 on this "Cinfo.php" file so i do not know why its sayin denied permission. thanx, ag3nt42 Quote Link to comment Share on other sites More sharing options...
Minase Posted June 10, 2008 Share Posted June 10, 2008 are you trying to write in the same file where script is? else maybe your permisions arent set corectly or another owner? Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 10, 2008 Author Share Posted June 10, 2008 no its not the same file.. I duno how else to set the permission then to chmod it to 7777 thats full access. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted June 10, 2008 Share Posted June 10, 2008 Make sure that the directory that the file is in has write permissions too. Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 10, 2008 Author Share Posted June 10, 2008 ok i've chmod my whole frikin website and it still doens't work code i'm using: <?php $file = fopen("Cinfo.php","w"); echo fputs($file,"This sux donkey ballz"); fclose($file); ?> errors i'm getting: Warning: fopen(Cinfo.php) [function.fopen]: failed to open stream: Permission denied in mypath/tester.php on line 4 Warning: fputs(): supplied argument is not a valid stream resource in mypath/tester.php on line 5 Warning: fclose(): supplied argument is not a valid stream resource in mypath/tester.php on line 6 Quote Link to comment Share on other sites More sharing options...
jonsjava Posted June 10, 2008 Share Posted June 10, 2008 If the file does exist: sounds like you don't have permission to chmod, or you didn't chmod it to 755/777 (either/or) If the file does not exist: same as above or your folder needs to be chmod'd to 666 Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 10, 2008 Author Share Posted June 10, 2008 i'm open to any suggestions here.. it doesn't even have to be the same way i'm doing it.. all i need is for to store some data on a txt file. And occasionally read it back into my code. REPLY [jonsjava] I chmod it again to 666 this time as well as the folder same exact error messages... how else to chmod then right click properties type in the 666 hit apply and done.. my ftp tells me attributes changed successfuly Quote Link to comment Share on other sites More sharing options...
jonsjava Posted June 10, 2008 Share Posted June 10, 2008 after you chmod it, refresh it, then right click on it and view its properties. If it doesn't say 0666 (or just 666) then you don't have permission to change the permissions. Quote Link to comment Share on other sites More sharing options...
Guest Xanza Posted June 10, 2008 Share Posted June 10, 2008 Try this: <?php $file = fopen("Cinfo.php","a+"); //maybe this will help echo fputs($file,"This sux donkey ballz"); fclose($file); ?> Other than that the only thing I can think of is your server has a problem with either fopen, or it's PHP install or something crazy like that. Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 10, 2008 Author Share Posted June 10, 2008 well i guess i'm just royaly screwed then, cuz I change the permissions then refresh and they are there for like a split second then its back to 0 no permissions checked... my user name for ftp is the same as my user account for windows inwhich I am admin, ftpuser, everyone. I have full control permission set with IIS5 on the entire webfolder directory. and nothing seems to be working. It still will not write to the file and I still get the exact same error messages.. I refuse to believe this can't be fixed but, there has got to be something we are missing here. Quote Link to comment Share on other sites More sharing options...
jonsjava Posted June 10, 2008 Share Posted June 10, 2008 Windows....? windows FTP doesn't handle Unix permission sets...... *palm-face*. It's not a permission issue. Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 10, 2008 Author Share Posted June 10, 2008 well i hope not cuz I have all the permissions i can give myself.. are the file system functions active by default? or do I have to set them in the ini? php manual claims they are part of the core no install. Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 10, 2008 Author Share Posted June 10, 2008 ok now i'm extremely irritated... used this code to check for writeability, <?php chown("Cinfo.php","ag3nt42"); echo fileowner("Cinfo.php"); $file = "Cinfo.php"; if(is_writable($file)) { echo ("$file is writeable"); } else { echo ("$file is not writeable"); } ?> returns: 0 Cinfo.php is writeable Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 10, 2008 Author Share Posted June 10, 2008 I have also tested this on 2 different servers... exact same results. Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 10, 2008 Author Share Posted June 10, 2008 anyone know of another way I can write to a txt file? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 10, 2008 Share Posted June 10, 2008 Who did it say the file owner was? And is ag3nt42 your system username? Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 10, 2008 Author Share Posted June 10, 2008 it claims the owner is 0 I tried using posix_getpwuid() to generate an actual name but apparently those functions are only available on unix based platforms ag3nt42 is my system name yes. i have full permission on everything.. i'm part of the admin group and ftp group Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 10, 2008 Share Posted June 10, 2008 Please don't tell me you're on a Windows box. Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 11, 2008 Author Share Posted June 11, 2008 yes i'm on windows... why? i think this is the first time nobody has been able to answer my question Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 11, 2008 Author Share Posted June 11, 2008 does anyone know of another way to do this: basically all i need is to take some form data and toss it into a txt file. so it can be read back in later. for example: I am creating an install file and I want to store the database connection info into a txt file so that my code can grab the info when it is needed. The information is obviously not static so how else can I do this? Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 11, 2008 Author Share Posted June 11, 2008 hahahahahahaha OMFG I ROCK!!!! yea so I had full permissions and admin has full permissions.. but does everyone?? they do now and just let me write to the file... wow.. thanx for the helpful input everyone Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted June 11, 2008 Author Share Posted June 11, 2008 can anyone tell me how this is working? I had to go through all this trouble to get php to write to my test file... meanwhile when I installed phpBB3 forum they are able to write to their config.php file without having to alter permission like I had to... on top of that.. when i went in to check the permissions on the file.. it had the same permissions as my Cinfo.php file BEFORE i altered them. So my questions is how is phpBB able to do this yet I cannot? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.