Web Analytics Made Easy -
StatCounter declaring variables in URL - CodingForum

Announcement

Collapse
No announcement yet.

declaring variables in URL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • declaring variables in URL

    Hi,

    Short version:
    page.php?message=hello

    How do i go about displaying 'hello' on the screen? (besides echo $message, that doesnt work)


    Longer version:
    I seem to be experiencing a bit of trouble when stating a $ within the url ie using:
    page.php?message=hello

    previously i could just echo $message it and would be fine, i recently moved hosting and they told me to add a php.ini file to by-pass there security system i guess, and thats worked fine, however now im using a different host for testing purposes and its giving me hell!

    Is there something im missing?
    in the past id link to pages with information like page.php?username=blaa
    and off it'd go happy as larry (and he's a pretty happy chap!) but now its having none of it.

    Im using sessions, though i'll admit i very rarely declare them properly, but im pretty sure this isnt the reason for the problems as this information doesnt need to be stored, it just need to be pointed out for this page.
    Any ideas?

    Thx

  • #2
    Your old host had register_globals turned on, your new host doesn't. It's not good practice to use the syntax of $message, for this very reason-- the code will not work in every PHP environment.

    What you want to use is the global array $_GET. Everything in the query string of a URL gets loaded into the $_GET array so you can refer to the value as $_GET['message'].

    Comment


    • #3
      Originally posted by Fumigator View Post
      Your old host had register_globals turned on, your new host doesn't. It's not good practice to use the syntax of $message, for this very reason-- the code will not work in every PHP environment.

      What you want to use is the global array $_GET. Everything in the query string of a URL gets loaded into the $_GET array so you can refer to the value as $_GET['message'].
      << + >>

      PHP Code:
      <?php
      $message 
      $_GET['message'];

      echo 
      $message;
      ?>
      www.b-a-k-e-r.com

      Comment

      Working...
      X