Results 1 to 12 of 12
  1. #1

    PHP variables not showing.

    Register globals is off , safe mode is off , i tried both ways but it still doesn't work.

    index.php
    ---
    <html>
    <head>
    <title>My Movie Site - <?php $_REQUEST['$favmovie']; ?></title>
    </head>
    <body>
    <?
    // define ("FAVMOVIE", "Patch Adams");
    echo "My favourite movie is ";
    echo $_REQUEST['$favmovie'];
    echo "<br>";
    $movierate = 5;
    echo "My movie rating for this movie is: ";
    echo $movierate;
    ?>
    </body>
    </html>
    ---

    movie1.php
    ---
    <html>
    <head>
    <title>Find my Favourite Movie!</title>
    </head>
    <body>
    <?
    echo "<a href='index.php?favmovie=Patch Adams'>";
    echo "Click here to see information about my favourite movie!";
    echo "</a>";
    ?>
    </body>
    </html>
    ---

    Patch Adams is not showing up. When it's on the same php page , it shows up. Any ideas?

  2. #2
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,441
    In the first one, you need to do either:
    PHP Code:
    <?=$_REQUEST['favmovie'];?>
    or
    PHP Code:
    <?php echo $_REQUEST['favmovie']; ?>
    and for the second one,
    PHP Code:
    echo $_REQUEST['favmovie']; 
    Hope that helps

  3. #3
    I added ECHO but erh... it's still not showing. Your code looks roughly the same , what's the difference?

  4. #4
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,099
    What version of PHP are you using? Your code should read:

    echo $_GET['favmovie']
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

  5. #5
    Join Date
    Nov 2005
    Location
    Ohio
    Posts
    9

  6. #6
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,441
    SyraLeo, you had $'s where they shouldn't have been.

    Double Tap, that only works when Register_Globals is on, and is generally bad practice since you rely on settings you cannot control, and it allows people to mess with your variables.

  7. #7
    What about having spaces in his _GET variables?

    favmovie=Patch Adams
    Is that ok? I really dont know, because I think its bad practice and do not do it myself. Maybe some else can comment.
    "The only difference between a poor person and a rich person is what they do in their spare time."
    "If youth is wasted on the young, then retirement is wasted on the old"

  8. #8
    Very good answers! thank you too!

  9. #9
    Using PHP5.05 , MySql 4.0.26 , Apache 1.3.3

    I'll try all that later. GET POST REQUEST all don't seem to work...

  10. #10
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,441
    REQUEST gets either GET or POST (IIRC), GET grabs from the URL, and POST grabs from form info.

    innova: As far as I know, GET variables can handle spaces. AFAIK, Apache converts them to %20 automatically, and should convert back once on the server.

    Haven't tried it myself though, since I only ever pass intergers or single words in a URL.

  11. #11
    Join Date
    Oct 2004
    Location
    Shimonoseki
    Posts
    2,101
    Quote Originally Posted by SyraLeo
    I added ECHO but erh... it's still not showing. Your code looks roughly the same , what's the difference?
    you added echo but did you remove the "$" sign ?
    Closed for winter...

  12. #12
    Yea i did , a friend pointed out to me the $ sign is missing , so i removed it and it worked. I feel so stupid now.. :/ All this trouble because of a $ sign.

Posting Permissions

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