• # August 14, 2009 at 1:15 am

    I have a variable that I want to send to another file to be echoed out to the screen. I tried sessions but no luck. I was searching and the searches say to use GET or POST but they aren’t working either. I don’t get anything when I try it, but then it could be wrong code. I have a hit counter that I am working on. The idea is to get the number from a file and then send that number to a different page to be seen. I want it like this so that no one else but me can see the numbers. Here is the hit counter that works. This will display the number to the screen if you make an index.php and an empty file called reader.txt.

    $filename= “reader.txt” ;

    $fd = fopen ($filename , “r”) or die (“Can’t open $filename”) ;

    $fstring = fread ($fd , filesize ($filename)) ;

    echo “$fstring”;

    fclose($fd) ;

    $fd = fopen ($filename , “w”) or die (“Can’t open $filename”) ;

    $fcounted = $fstring + 1 ;

    $fout= fwrite ($fd , $fcounted ) ;

    fclose($fd) ;

    I don’t know why the code is written this way, I have been following a tutorial. What I want to do is be able to use $fstring in another page. I want to be able to include this code in one page without it showing the results on that particular page. I think this makes sense.

    # August 14, 2009 at 2:41 am

    This reply has been reported for inappropriate content.

    I will look into this when back from work…… I just checked out files in PHP the other day and have mine working the way I want it to

    # August 14, 2009 at 2:44 am

    This reply has been reported for inappropriate content.

    well the simplest sollution I was able to figure out was to put the code that reads the file into the other page that I want to beable to use the variable. Then I just subtracted one from the count and all was good. But I want to know the real way to do it for future use. There has to be a better way.

    # August 14, 2009 at 12:45 pm

    This reply has been reported for inappropriate content.

    this should work…


    I can write via my contact script, but I can’t seem to open a file with this, maybe there is something wrong with my servers php implementation


    this does work perfectly


    the to be read by you in another page

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.