Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

FWrite

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Spacemail by SpaceshipSpacemail by 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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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
Close
did you make sure the file is writable by the script?
 
0
Close
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
Close
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
Close
how do i set it to 777 or 666?
 
0
Close
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
Close
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
Close
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
Close
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
Close
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
Close
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
Close
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
Close
0
Close
Yes that is where you get smartFTP from.

iNod
 
0
Close
0
Close
well. if your on a unix os then you could set the attributes from the os by using
'chmod 666;
 
0
Close
Appraise.net

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back