468,161 Members | 1,936 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,161 developers. It's quick & easy.

Cannot open file

Hi
I have my home directory on my departments server. Somehow I am not
able to write to a file using a php code,
$myFile = "trial3.txt";
$fh = fopen($myFile, "a+") or die("can't open file");

Instead of a+ if i use r or w or anything, it does not work. Could this
be a permission thing? The entire directory had a 777 permission and
even i after i created a file and chmod'ed 777 to it, the code couldnt
open it. What could be the matter? It doesnt go away if i change it to
'w' or 'w+' or 'r' or 'r+'.

Rahul

Dec 2 '06 #1
6 3097
Also I wanted to add that if i write a perl script to write to a file,
it does it for me. But some how that is not possible in php. I gave
write permissions to all the php files and all the text files.

Rahul
rahulthathoo wrote:
Hi
I have my home directory on my departments server. Somehow I am not
able to write to a file using a php code,
$myFile = "trial3.txt";
$fh = fopen($myFile, "a+") or die("can't open file");

Instead of a+ if i use r or w or anything, it does not work. Could this
be a permission thing? The entire directory had a 777 permission and
even i after i created a file and chmod'ed 777 to it, the code couldnt
open it. What could be the matter? It doesnt go away if i change it to
'w' or 'w+' or 'r' or 'r+'.

Rahul
Dec 2 '06 #2
rahulthathoo wrote :
Also I wanted to add that if i write a perl script to write to a file,
it does it for me. But some how that is not possible in php. I gave
write permissions to all the php files and all the text files.

Rahul
rahulthathoo wrote:
>Hi
I have my home directory on my departments server. Somehow I am not
able to write to a file using a php code,
$myFile = "trial3.txt";
$fh = fopen($myFile, "a+") or die("can't open file");

Instead of a+ if i use r or w or anything, it does not work. Could this
be a permission thing? The entire directory had a 777 permission and
even i after i created a file and chmod'ed 777 to it, the code couldnt
open it. What could be the matter? It doesnt go away if i change it to
'w' or 'w+' or 'r' or 'r+'.

Rahul
Did you try running your PHP script in a shell, instead of in a browser?

--
Naixn
http://fma-fr.net
Dec 2 '06 #3
No i opened up the php script in the browser. how do i parse it in the
shell?
rahul

naixn wrote:
rahulthathoo wrote :
Also I wanted to add that if i write a perl script to write to a file,
it does it for me. But some how that is not possible in php. I gave
write permissions to all the php files and all the text files.

Rahul
rahulthathoo wrote:
Hi
I have my home directory on my departments server. Somehow I am not
able to write to a file using a php code,
$myFile = "trial3.txt";
$fh = fopen($myFile, "a+") or die("can't open file");

Instead of a+ if i use r or w or anything, it does not work. Could this
be a permission thing? The entire directory had a 777 permission and
even i after i created a file and chmod'ed 777 to it, the code couldnt
open it. What could be the matter? It doesnt go away if i change it to
'w' or 'w+' or 'r' or 'r+'.

Rahul

Did you try running your PHP script in a shell, instead of in a browser?

--
Naixn
http://fma-fr.net
Dec 2 '06 #4
rahulthathoo wrote :
No i opened up the php script in the browser. how do i parse it in the
shell?
Symply type :
$php your_file.php

( '$>' being the shell prompt, in case of )

Not too hard, eh? :)

--
Naixn
http://fma-fr.net
Dec 2 '06 #5
Alright it works in the shell, but now when i open the url in the
browser. What could be wrong?

Rahul

naixn wrote:
rahulthathoo wrote :
No i opened up the php script in the browser. how do i parse it in the
shell?

Symply type :
$php your_file.php

( '$>' being the shell prompt, in case of )

Not too hard, eh? :)

--
Naixn
http://fma-fr.net
Dec 2 '06 #6
I meant not* - it doesnt write the file when i open the url in the
browser

Rahul
rahulthathoo wrote:
Alright it works in the shell, but now when i open the url in the
browser. What could be wrong?

Rahul

naixn wrote:
rahulthathoo wrote :
No i opened up the php script in the browser. how do i parse it in the
shell?
>
Symply type :
$php your_file.php

( '$>' being the shell prompt, in case of )

Not too hard, eh? :)

--
Naixn
http://fma-fr.net
Dec 2 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Christopher Brandsdal | last post: by
5 posts views Thread by Sanyi | last post: by
1 post views Thread by vikram | last post: by
2 posts views Thread by Jay Bienvenu | last post: by
2 posts views Thread by John Donnell | last post: by
1 post views Thread by edfialk | last post: by
1 post views Thread by gcdp | last post: by
reply views Thread by gcreed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.