Results 1 to 8 of 8

Thread: PHP variables

  1. #1
    Advisor
    Join Date
    Apr 2002
    Posts
    858

    PHP variables

    My variables in PHP don't seem to be working as they should. If I make a simple file like so:

    <html>
    <body>
    <?php
    echo "$testage";
    ?>
    </body>
    </html>

    and then go to it using http://www.myserver.com/filename.php?testage=words The file displays nothing. If I add the line:

    $testage = "words";

    to the php file it works fine and displays the value of $testage. Does anyone know why I can't send variables this way to my php files? I can't seem to send them any other way either (using forms). Any help would be much appreciated!

  2. #2

    Re: PHP variables

    You need something to catch the variables. Look at phpnuke source for some good examples.

    Something like switch($variableName) would probably work.

  3. #3
    Advisor
    Join Date
    Apr 2002
    Posts
    858

    Re: PHP variables

    Okay...that's not really the answer i was looking for . If I go to another server using the same file, then use filename.php?testage=word it outputs "word" as the file. I seem to remember something about "enable_track_vars" or something like that...I think that was needed during setup of PHP (I used a different tutorial for setup on this server). Is this right? Any thoughts? I should be able to do this without adding any code to the php...I'm sure of this. If I do need to add another attribute for php, would I have to reinstall it? Thanx for the help so far.

  4. #4

    Re: PHP variables

    You are using mod_php on Apache right?

  5. #5
    Advisor
    Join Date
    Apr 2002
    Posts
    858

    Re: PHP variables

    I'm loading php into apache as a DSO

  6. #6
    Mentor coltrane's Avatar
    Join Date
    May 2001
    Location
    North Carolina
    Posts
    1,390

    Re: PHP variables

    What exactly are you striving to accomplish? I need a real-world example in order to help you out with this.

    So far my understanding is that youre trying to set the value of the variable through the browser.....is that correct ?

  7. #7
    Advisor
    Join Date
    Apr 2002
    Posts
    858

    Re: PHP variables

    Okay, my real world example is as you guessed, I have a file like this:

    <html>
    <body>
    <?php
    echo "$testage";
    ?>
    </body>
    </html>

    and I'm trying to set the variable testage from the browser. On my Apache server with PHP loaded in as a DSO the variable can't be passed through the browser. My guess is that PHP is somehow set up incorrectly, I'm wondering if anyone knows how to fix the problem.

    filename.php?testage=value

    gives me nothing.

  8. #8
    Advisor
    Join Date
    Apr 2002
    Posts
    858

    Re: PHP variables

    Okay I got it figured out. I needed to configure php with --with-enable-track-vars when I installed it. I reinstalled doing this now it works as it should.

    Thanx for all the help guys!

Similar Threads

  1. dns - variables
    By 4ever in forum Linux - Hardware, Networking & Security
    Replies: 1
    Last Post: 02-02-2009, 09:32 PM
  2. Reading variables...
    By Gary Penner in forum Linux - Software, Applications & Programming
    Replies: 1
    Last Post: 02-25-2005, 10:35 PM
  3. Environment variables... where should they go?
    By krupa in forum Linux - General Topics
    Replies: 5
    Last Post: 11-27-2001, 03:14 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •