Jump to content

fopen failing but no error


rainbowsntoffee

Recommended Posts

Hi,

please bear with me as my problem may be glaringly obvious as I am new to this.  :(

Basically I have a super-duper length string (about 50 lines worth) which i need to save to an arbitrary filename.php

This is the code to do that, obviously with the file name stored in $filename

 

//open file (create if non-existant)

$filename = $name.".php";

$file = fopen($filename, "w+") or die('error file open');

//write back

fwrite($file, $towrite);

fclose($file);

chmod($filename, 0755);

 

I rough-tested this code on a free host (leadhoster) and after a few mis-starts it worked fine. I then transferred the code to a new host (easily) which is when my problems began.

 

It doesn't manage to open the file- dies every time. However it doesn't give me an error either.

I thought it might be the die suppressing the error and removed it but nothing happened that time either,

the folder and file both have 0755 permissions.

The folder structure is the same on both hosts.

I've tried with file pre-existing and non-existing,

the phpinfo states the fopen bits are on,

easily run php5.16 by the way.

 

Can anybody think of a reason why this would not work on the newer server?

Link to comment
https://forums.phpfreaks.com/topic/121668-fopen-failing-but-no-error/
Share on other sites

ProjectFear - Sorry, I forgot to mention that I already tried the error_reporting(E_ALL) line. No errors/warnings/anything else are displayed. 

 

kratsg, I maybe didn't write that clearly enough (Sorry again!) but it does give me the die error, just obviously thats not an explanation of why it has decided to hate me  ;)

I'd sign up to the posher version of the original host but now its sort of personal, you know? I've been swearing at the stupid thing for the best part of two weeks..  ::)

oh wow! errors! Thanks PFMaBiSmAd

 

Warning: fopen(/home/.sites/20/site458/web/includes/new.php) [function.fopen]: failed to open stream: Permission denied in /home/.sites/20/site458/web/updatemainf.php on line 297

 

The script using fopen is in the web folder.

I've tried:

new.php

/includes/new.php

include/new.php

obviously, the whole lot as above,

http://the address for it all

 

 

The web folder is set to 777 permissions, the includes to 755.

I'm guessing it's something in the settings. What am I looking for? the obvious setting including fopen is set to on, which I presume is a good thing?

Help please!  :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.