$_GET[], $_POST problems

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
TuffGong
Forum Newbie
Posts: 5
Joined: Wed Jun 12, 2002 6:00 am

$_GET[], $_POST problems

Post by TuffGong »

i been writing huge scripts on my local machine which runs a Apache server, with MYSQL installed as a service, and PHP modules too.

The problem is, my scripts work perfectly offline, when uploaded to my server which also uses Apache, variables passed in the URL, are not retreived using $_GET['name'] method

for instance:

a url such as
http://www.aljam.co.uk?Action=Login

would be processed in my script as:

Action = $_GET[Login];

but Action is never assigned a value when testing online??

i've also tried using $_POST but to no avail, this is frustrating because the problem occurs only online!

is there any server configuration required? maybe something to do with register globals?


M
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What version of PHP is being run on the server?

One possible cause of this would be having an older version of PHP on the server than you do on your development machine. To find out the version of PHP being used on the server put

Code: Select all

<?php echo 'PHP version is: '.phpversion(); ?>
into a file and upload it to the server. When it is run you'll get the current PHP version number, if that is less than 4.1, (eg. 4.0.6) then you cannot use $_POST, $_GET etc. instead you need to use $HTTP_POST_VARS, $HTTP_GET_VARS etc.

Mac
TuffGong
Forum Newbie
Posts: 5
Joined: Wed Jun 12, 2002 6:00 am

thanks

Post by TuffGong »

mate, ur a lifesaver, i checked the version and my server is still using version 4.0.1 .... they shou8ld keep up eh?!

one more thing could u give a example of using $HTTP_POST_VARS and $HTTP_GET_VARS im guessing its identical to $_GET ?

M
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

The $HTTP_xxx_VARS arrays are the same as the $_POST, $_GET etc arrays in that you access the data the same way so:

Code: Select all

$HTTP_GET_VARS&#1111;'action'] === $_GET&#1111;'action']
However whilst the new arrays are autoglobals the old ones aren't - if you want to access them in a function you need to declare them as globals so,

Code: Select all

function my_function ()
&#123;
    global $HTTP_POST_VARS, $HTTP_GET_VARS;
    // function
&#125;
More information about the predefined variables is available here:
http://www.php.net/manual/en/reserved.variables.php

Mac
Post Reply