Zymic Forums

Webmaster resources

Zymic IRC Server

Chat in real time at irc.zymic.com - Learn More

Welcome

Welcome to the Zymic webmaster forums. Our forums are here to provide people the free ability to discuss a range of websites related topics such as design, development coding and marketing.

In order to post you will need to register for a zymic account or if you already have one simply login by using the form on the left.

left Zymic Webmaster ForumsWeb Design & DevelopmentServer Side ScriptingPHP right
  Reply to this topic Start new topic
left right
ugser
post Nov 6 2009, 04:33 AM
Post #1


Newbie
*

Group: Members
Posts: 3
Joined: 6-November 09
Member No.: 117,173



Text file is 'msg/nik.dat'.
Function file_exists('msg/nik.dat') return true.
Warning fopen('msg/nik.dat','w') failed to open stream: No such file or directory
Warning fopen('/msg/nik.dat','w') failed to open stream: No such file or directory
Warning fopen('./msg/nik.dat','w') failed to open stream: No such file or directory
What is right.
Go to the top of the page 
 
  + Quote Post
herb2006
post Nov 6 2009, 09:27 AM
Post #2


Member
**

Group: Members
Posts: 72
Joined: 11-October 09
From: GuangZhou,China
Member No.: 113,472



QUOTE(ugser @ Nov 6 2009, 04:33 AM) *
Text file is 'msg/nik.dat'.
Function file_exists('msg/nik.dat') return true.
Warning fopen('msg/nik.dat','w') failed to open stream: No such file or directory
Warning fopen('/msg/nik.dat','w') failed to open stream: No such file or directory
Warning fopen('./msg/nik.dat','w') failed to open stream: No such file or directory
What is right.


chmod("msg/nik.dat",0666); first! hunter.gif
Go to the top of the page 
 
  + Quote Post
ugser
post Nov 7 2009, 12:01 AM
Post #3


Newbie
*

Group: Members
Posts: 3
Joined: 6-November 09
Member No.: 117,173



QUOTE(herb2006 @ Nov 6 2009, 09:27 AM) *
chmod("msg/nik.dat",0666); first! hunter.gif


CODE
$f = "msg/nik.dat";
chmod($f,0666);
$fp = fopen($f,"w");
if (file_exist($f)==true){
//Warning: chmod() Operation not permitted
}
else
{
//Warning: chmod() Unable to access msg/nik.dat
//Warning: chmod() stat failed for msg/nik.dat
//Warning: fopen(msg/nik.dat) Permission denied
}

Where is mistake
For $f = "./nik.dat" - all good without chmod .
Go to the top of the page 
 
  + Quote Post
herb2006
post Nov 8 2009, 06:01 AM
Post #4


Member
**

Group: Members
Posts: 72
Joined: 11-October 09
From: GuangZhou,China
Member No.: 113,472



QUOTE(ugser @ Nov 7 2009, 12:01 AM) *
Where is mistake
For $f = "./nik.dat" - all good without chmod .


I am sorry for that.
your script have no mistakes, the cause is permission limit.
the cause of the warnings , Warning fopen('msg/nik.dat','w') failed to open stream, is fopen have no perms to 'w' file.
so we must
set perms to the folder msg first, should set 0777.
then set perms to the file nik.dat, should set 0666.

then the function fopen will work!

file permissions should be changed under FTP, such as FlashFXP, not through php script,
but via the file manager of Zymic, you can also finish such work.
(0777 = rwxrwxrwx ; 0666 = rw-rw-rw-)
Go to the top of the page 
 
  + Quote Post
ugser
post Nov 9 2009, 04:06 AM
Post #5


Newbie
*

Group: Members
Posts: 3
Joined: 6-November 09
Member No.: 117,173



QUOTE(herb2006 @ Nov 8 2009, 06:01 AM) *
I am sorry for that.
your script have no mistakes, the cause is permission limit.
the cause of the warnings , Warning fopen('msg/nik.dat','w') failed to open stream, is fopen have no perms to 'w' file.
so we must
set perms to the folder msg first, should set 0777.
then set perms to the file nik.dat, should set 0666.

then the function fopen will work!

file permissions should be changed under FTP, such as FlashFXP, not through php script,
but via the file manager of Zymic, you can also finish such work.
(0777 = rwxrwxrwx ; 0666 = rw-rw-rw-)

Thank you very mach.
I set perms to the folder in File Manager.All right if a new file.
If already a file exists then need unlink before fopen.chmod - error.
I'm from Ukraine.1 time PHP.I design Clarion.
CODE
function saveFile($f,$contents,$mode="w"){
if(file_exists($f)==true)unlink($f);
$fo=fopen($f, $mode);
flock ($fo,LOCK_EX);
ftruncate ($fo,0);
$result=fwrite($fo,$contents);
fflush ($fo);
flock ($fo,LOCK_UN);
fclose($fo);
return $result;
}

Go to the top of the page 
 
  + Quote Post
herb2006
post Nov 9 2009, 07:56 AM
Post #6


Member
**

Group: Members
Posts: 72
Joined: 11-October 09
From: GuangZhou,China
Member No.: 113,472



QUOTE(ugser @ Nov 9 2009, 04:06 AM) *
Thank you very mach.
I set perms to the folder in File Manager.All right if a new file.
If already a file exists then need unlink before fopen.chmod - error.
I'm from Ukraine.1 time PHP.I design Clarion.


rolleyes.gif
Go to the top of the page 
 
  + Quote Post
 Reply to this topic Start new topic
left right
0 Members:
left right
 


Lo-Fi Version Time is now: 21st November 2009 - 12:40 AM