NameSilo

FWrite

Spaceship Spaceship
Watch

Barrucadu

Established Member
Impact
64
I cant get it to work, heres the code, what am I doing wrong?

PHP:
$handle = fopen('users.log',w);
if(!fwrite($handle, "UID: ".$_POST['uid']."PCO: ".$_POST['pcode']."EMA: ".$_POST['email']."FNA: ".$_POST['fname']."SNA: ".$_POST['sname'])) {
	echo( '<center>Error creating user profile!<p><a href = \'register.php\'>Try Again</a></p></center>');
	exit;
}else {
	echo( '<center>Registration complete!<p><a href = \'index.php\'>Continue</a></p></center>');
	exit;
}

when I run that above code (all the _POST variables are predefined) the file remains empty. whats wrong with it?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
PHP:
$handle = fopen('users.log', 'w+');
if(!fwrite($handle, "UID: ".$_POST['uid']."PCO: ".$_POST['pcode']."EMA: ".$_POST['email']."FNA: ".$_POST['fname']."SNA: ".$_POST['sname'])) {
    echo( '<center>Error creating user profile!<p><a href = \'register.php\'>Try Again</a></p></center>');
    exit;
}else {
    echo( '<center>Registration complete!<p><a href = \'index.php\'>Continue</a></p></center>');
    exit;
}
Not totally sure, but try that.
 
0
•••
did you make sure the file is writable by the script?
 
0
•••
Outer said:
did you make sure the file is writable by the script?
Yes, need to set it to either 777 or 666. :p And the only thing i noticed was wrong is that the w was not in '' quotes ;) hehe... make sure your file is writable and try the changes.. should work..
 
0
•••
To chamod you can use ftp or file manager in cpanel and select the file then either right click of select chmod action.

Regards,
 
Last edited:
0
•••
how do i set it to 777 or 666?
 
0
•••
Mikor said:
how do i set it to 777 or 666?
If you are using an FTP program, (like I use smartFTP) just select the file right-click, and select properties/CHMOD.. then set to 666 or 777...
 
0
•••
This:

PHP:
 $handle = fopen('users.log',w);

Should be this:

PHP:
 $handle = fopen('users.log','w');

The W needs to be in quotes. I have had this issue before.

And as others have said, your file need to be writable. Usually what I do is create a file of 1 byte on my hard drive, upload it, then change the permissions in ftp. You can do it at the shell prompt too.

-Bob
 
0
•••
SecondVersion said:
....... wrong is that the w was not in '' quotes hehe... make sure your file is writable and try the changes.. should work..
moondog said:
The W needs to be in quotes.

Like I said^^ ;)
 
0
•••
SecondVersion said:
If you are using an FTP program, (like I use smartFTP) just select the file right-click, and select properties/CHMOD.. then set to 666 or 777...


hmm ive got smartFTP but when i right-click/properties it dosnt give me a CHMOD option.
 
0
•••
Mikor said:
hmm ive got smartFTP but when i right-click/properties it dosnt give me a CHMOD option.
Right-Click on your file (users.log)
Select "Properties/CHMOD"
You'll see a box labeled "Permissions"
Type in 777
Click "Ok"
;)

SecondVersion said:
Right-Click on your file (users.log)
Select "Properties/CHMOD"
You'll see a box labeled "Permissions"
Type in 777
Click "Ok"
;)
And I've saw your other thread...

Remember, that
PHP:
 $handle = fopen('users.log',w);
The w must be in '' like
PHP:
 $handle = fopen('users.log', 'w');
 
0
•••
SecondVersion said:
Right-Click on your file (users.log)
Select "Properties/CHMOD"
You'll see a box labeled "Permissions"
Type in 777
Click "Ok"
;)

I dont thing you understand, there is no box labeled "Permissions" and there is no Properties/CHMOD, tehre is just Properties.
 
0
•••
Mikor said:
I dont thing you understand, there is no box labeled "Permissions" and there is no Properties/CHMOD, tehre is just Properties.
Then you must not be using the same "SmartFTP" I am ;)
 
0
•••
0
•••
Yes that is where you get smartFTP from.

iNod
 
0
•••
0
•••
well. if your on a unix os then you could set the attributes from the os by using
'chmod 666;
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back