Professional Web Applications Themes

GET ? parameters not accessible - PHP Development

I have a page with links that have parameters like "news.php?news_id=12345". When this link is taken (as I understand it) the "news.php" page should have access to a variable "news_id" with a value of "12345". But due to some weirdness I can't figure out the variable is not defined on the page after taking the link! I have done this before on other websites using the same versions of PHP so I can't quite see what the problem is now. Do I need session_start() ? I have put that in at the top of the page. Shouldn't I be able ...

  1. #1

    Default GET ? parameters not accessible

    I have a page with links that have parameters like "news.php?news_id=12345".

    When this link is taken (as I understand it) the "news.php" page should have
    access to a variable "news_id" with a value of "12345". But due to some
    weirdness I can't figure out the variable is not defined on the page after
    taking the link!

    I have done this before on other websites using the same versions of PHP so
    I can't quite see what the problem is now. Do I need session_start() ? I
    have put that in at the top of the page. Shouldn't I be able to refer to
    this variable as $news_id on the page? e.g.:

    if ( !isset ( $news_id ) ) {
    ...
    } else
    ...

    Thanks
    Mark


    Mark Guest

  2. #2

    Default Re: GET ? parameters not accessible

    Hi Mark
    > I have a page with links that have parameters like
    > "news.php?news_id=12345".
    >
    > When this link is taken (as I understand it) the "news.php"
    > page should have access to a variable "news_id" with a value
    > of "12345". But due to some weirdness I can't figure out the
    > variable is not defined on the page after taking the link!
    Well, there is a config option on PHP which allows to register globals
    (for instance GET-Variables) automatically. If this option is turned
    on, each transmitted Variable is then acessible by its name
    ($news_id) - this is what you most probably have set on the first
    server. Now it seems, on the second server it is turned off (probably
    for security purposes). However, by default it is turned off.

    You may access the variables now by using superglobals:

    $_GET['news_id']

    Or by putting a file named .htaccess in the directory where your
    scripts reside, containing the following line:

    php_flag register_globals on

    Greetings, Greg


    Gregor Favre Guest

  3. #3

    Default Re: GET ? parameters not accessible

    > I have a page with links that have parameters like
    "news.php?news_id=12345".
    >
    > When this link is taken (as I understand it) the "news.php" page should
    have
    > access to a variable "news_id" with a value of "12345". But due to some
    > weirdness I can't figure out the variable is not defined on the page after
    > taking the link!
    >
    > I have done this before on other websites using the same versions of PHP
    so
    > I can't quite see what the problem is now. Do I need session_start() ? I
    > have put that in at the top of the page. Shouldn't I be able to refer to
    > this variable as $news_id on the page? e.g.:
    try $GET['news_id'] it maybe that register globals is turned off


    Filth Guest

  4. #4

    Default Re: GET ? parameters not accessible

    > try $GET['news_id'] it maybe that register globals is turned off
    oops meant $_GET['news_id']


    Filth Guest

  5. #5

    Default Re: GET ? parameters not accessible


    "Mark" <dummyaddyreallyisfake.com> wrote in message
    news:9p%Cc.40272$ly2.28093doctor.cableinet.net...
    > I have a page with links that have parameters like
    "news.php?news_id=12345".
    >
    > When this link is taken (as I understand it) the "news.php" page should
    have
    > access to a variable "news_id" with a value of "12345". But due to some
    > weirdness I can't figure out the variable is not defined on the page after
    > taking the link!
    >
    > I have done this before on other websites using the same versions of PHP
    so
    > I can't quite see what the problem is now. Do I need session_start() ? I
    > have put that in at the top of the page. Shouldn't I be able to refer to
    > this variable as $news_id on the page? e.g.:
    >
    > if ( !isset ( $news_id ) ) {
    > ...
    > } else
    > ...
    >
    > Thanks
    > Mark
    >
    >
    This may be a good thing. If you have register globals (I think that's what
    it's called) off, which is more secure, you must access $news_id not through
    that variable but rather through $_GET['news_id']. This is a much more
    secure method and I would seriously suggest not changing it. This has been
    around since, I believe, PHP 4.1.

    And no, you don't need session_start(). That's for a cookie.

    -- Matt


    Matthew Del Buono Guest

  6. #6

    Default Re: GET ? parameters not accessible

    > This may be a good thing. If you have register globals (I think that's
    what
    > it's called) off, which is more secure, you must access $news_id not
    through
    > that variable but rather through $_GET['news_id']. This is a much more
    > secure method and I would seriously suggest not changing it. This has been
    > around since, I believe, PHP 4.1.
    >
    > And no, you don't need session_start(). That's for a cookie.
    session_start() is not just for cookies, sessions can be held on the server
    as well but you are correct he does not need it


    Filth Guest

  7. #7

    Default Re: GET ? parameters not accessible

    Thanks guys for all your answers... that has fixed the problem! I was using
    my local server and forgot my last project was on a remote one!

    Mark

    "Mark" <dummyaddyreallyisfake.com> wrote in message
    news:9p%Cc.40272$ly2.28093doctor.cableinet.net...
    > I have a page with links that have parameters like
    "news.php?news_id=12345".
    >
    > When this link is taken (as I understand it) the "news.php" page should
    have
    > access to a variable "news_id" with a value of "12345". But due to some
    > weirdness I can't figure out the variable is not defined on the page after
    > taking the link!
    >
    > I have done this before on other websites using the same versions of PHP
    so
    > I can't quite see what the problem is now. Do I need session_start() ? I
    > have put that in at the top of the page. Shouldn't I be able to refer to
    > this variable as $news_id on the page? e.g.:
    >
    > if ( !isset ( $news_id ) ) {
    > ...
    > } else
    > ...
    >
    > Thanks
    > Mark
    >
    >


    Mark Guest

Similar Threads

  1. PPD options not accessible
    By Gernot_Hoffmann@adobeforums.com in forum Adobe Indesign Windows
    Replies: 22
    Last Post: May 12th, 01:11 PM
  2. Scanning accessible PDF
    By john_cummins@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 1
    Last Post: April 20th, 04:04 PM
  3. Sprites behind transparent 3d accessible?
    By Khanh75 webforumsuser@macromedia.com in forum Macromedia Director 3D
    Replies: 0
    Last Post: December 3rd, 05:46 PM
  4. create parameters without creating parameters
    By dan marks in forum ASP Components
    Replies: 0
    Last Post: October 30th, 01:51 AM
  5. WinXP PC's not accessible in LAN
    By Kamen Damianov in forum Windows Networking
    Replies: 1
    Last Post: July 17th, 02:02 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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139