Simple PHP 2

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TRPlace
Forum Newbie
Posts: 3
Joined: Fri Mar 10, 2006 7:19 pm

Simple PHP 2

Post by TRPlace »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Thanks for the help. I am still having a little bit of trouble.
> I don't understand what the super global is, but right now I don't think it's too important
> I revised the code a little to show a couple examples of problems I am having

Code:

Code: Select all

<?PHP
    function WriteToFile(){
        global $yesPercentage;
      //echo($yesPercentage."HERE");
      echo("HERE".$yesPercentage);
        // or you can use the superglobal $_POST var
        $filename="/home/content/w/h/y/whyworkforever/html/test/test.txt";
        $file=fopen($filename,"w");
        fwrite($file,$yesPercentage); // $yesPercentage needs to be globalized
        fclose($file);
    }
    function Read(){
        $filename="/home/content/w/h/y/whyworkforever/html/test/test.txt";
        $file=fopen($filename,"r");
        echo($file);
        fclose($file);
    }

    //$yesPercentage = $_POST['yesPercentage']; // set the value of $yesPercentage
    echo("yesPercentage=".$yesPercentage);
?>
In the line here....[exerpt]
Code:

Code: Select all

global $yesPercentage;
//echo($yesPercentage."HERE");
echo("HERE".$yesPercentage);
Either way I echo it, it tries to go to a website....in my case it goes to http://www.whyworkforever.org/test/HERE, and the starting URL is http://www.whyworkforever.org/test/test.php

The globalization did help, and I do remember that from my VB classes, but it has been a while so I needed a refresher, thanks Very Happy

Also I have a link in the HTML...
Code:

Code: Select all

<a href=http://www.whyworkforever.org/test/test.php?Read>HERE</a>
I want it to process that function, but it just refreshes the page, but I think that could be part of that echo problem I am having.

I was going to try to put in a "return $yesPercentage" line in the WriteToFile function, but I thought I would get one thing done at a time.

I hope this was well explained so some kind person can help. Thanks for your fast response on the previous message.

It's weird how some of the easiest things get forgotten, but once they get refreshed in your memory, other things start to get unlocked and remembered.


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Post Reply