fert Posted June 9, 2006 Share Posted June 9, 2006 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 functionsPlease help Quote Link to comment https://forums.phpfreaks.com/topic/11600-php-code-error/ Share on other sites More sharing options...
Orio Posted June 9, 2006 Share Posted June 9, 2006 Tried adding () ...?I think it's the only problem.Orio. Quote Link to comment https://forums.phpfreaks.com/topic/11600-php-code-error/#findComment-43783 Share on other sites More sharing options...
fert Posted June 9, 2006 Author Share Posted June 9, 2006 [!--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 codeEDIT: I found the problem in the fread part the second argument wasn't the right file. Quote Link to comment https://forums.phpfreaks.com/topic/11600-php-code-error/#findComment-43786 Share on other sites More sharing options...
Fyorl Posted June 9, 2006 Share Posted June 9, 2006 use file_get_contents instead of fopen, fread... and why are you writing to a new file at the bottom? Also, you might want to put quotes "" around your $num_users variable when you write it to the file. Like: @ fwrite [$file, "$num_users"] Quote Link to comment https://forums.phpfreaks.com/topic/11600-php-code-error/#findComment-43788 Share on other sites More sharing options...
poirot Posted June 9, 2006 Share Posted June 9, 2006 [!--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\" /] Quote Link to comment https://forums.phpfreaks.com/topic/11600-php-code-error/#findComment-43789 Share on other sites More sharing options...
Fyorl Posted June 9, 2006 Share Posted June 9, 2006 [!--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... Quote Link to comment https://forums.phpfreaks.com/topic/11600-php-code-error/#findComment-43792 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.