Jump to content

PHP code error


fert

Recommended Posts

Okay, this PHP code i'm using in the register part and the part of code that counts users dosen't work (It resets the number of users to 1)
[code]
$file=@fopen"_private/num_of_users.txt","r" or die"Sorry profile couldn't be created";
    $num_users=@fread($file,filesize($file));
    
    $num_users=$num_users+1;
    @fclose$file;
    
    $file=@fopen"_private/num_of_users.txt","w+" or die"Sorry profile couldn't be created";
    @fwrite$file,$num_users;
    @fclose($file);
        
    
    $file=@fopen$newfilename2,"w+";
    @fwrite$file,$num_users;
    @fclose$file;
[/code]
I know I don't have () in the functions
Please help
Link to comment
https://forums.phpfreaks.com/topic/11600-php-code-error/
Share on other sites

[!--quoteo(post=381999:date=Jun 9 2006, 12:53 PM:name=Orio)--][div class=\'quotetop\']QUOTE(Orio @ Jun 9 2006, 12:53 PM) [snapback]381999[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Tried adding () ...?
I think it's the only problem.

Orio.
[/quote]
No i took out the () so the forums would let post code

EDIT: I found the problem in the fread part the second argument wasn't the right file.
Link to comment
https://forums.phpfreaks.com/topic/11600-php-code-error/#findComment-43786
Share on other sites

[!--quoteo(post=382004:date=Jun 9 2006, 12:08 PM:name=Fyorl)--][div class=\'quotetop\']QUOTE(Fyorl @ Jun 9 2006, 12:08 PM) [snapback]382004[/snapback][/div][div class=\'quotemain\'][!--quotec--]
use file_get_contents instead of fopen, fread... and why are you writing to a new file at the bottom?
[/quote]
file_get_contents was added as of PHP 4.30..

Anyways, he fixed it [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
Link to comment
https://forums.phpfreaks.com/topic/11600-php-code-error/#findComment-43789
Share on other sites

[!--quoteo(post=382005:date=Jun 9 2006, 02:09 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 9 2006, 02:09 PM) [snapback]382005[/snapback][/div][div class=\'quotemain\'][!--quotec--]
file_get_contents was added as of PHP 4.30..

Anyways, he fixed it [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
[/quote]
A lot of functions were added as of PHP 4, doesn't mean we should only use PHP 3 functions...
Link to comment
https://forums.phpfreaks.com/topic/11600-php-code-error/#findComment-43792
Share on other sites

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.