Page 1 of 1

$_server array (registered global)

Posted: Thu Oct 14, 2004 4:44 pm
by Pizmal
Is the $_Server array blocked if the registered_globals set to off?

--Pizml

Posted: Thu Oct 14, 2004 4:47 pm
by LostMyLove
no

Posted: Thu Oct 14, 2004 4:52 pm
by m3mn0n
More info: [php_man]register_globals[/php_man]

Posted: Thu Oct 14, 2004 4:55 pm
by Pizmal
Only reason i am asking is cause i cant get website to post to Mysql without registered globals on. :( Other than $_SERVER and common variables all I have is a carry over id variable through a url.

From
pizmal

Posted: Thu Oct 14, 2004 5:00 pm
by Draco_03
post your code here
ps : how the get is coded?

Posted: Thu Oct 14, 2004 5:05 pm
by Pizmal
This "get" you are refering to is the ID varible I use in a url. I never set

$_get['id'] = $id

I just put in in the url like so:

Code: Select all

print "<td><a href="inkrequest.php?id=$row[workorder_id]">".stripslashes($row['workorder_id'])."</a></td>";
}

Posted: Fri Oct 15, 2004 3:20 am
by twigletmac
How do you retrieve the value from the URL?

Mac

Posted: Fri Oct 15, 2004 6:22 am
by Pizmal
twigletmac | Help us, help you. Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

I simply use the varible on the next page to test for it.

Code: Select all

IF (! empty($ID) {

( DO  FOO)

} ELSE {

(DO BAR)

}
I didnt know it mattered how I used the variable once i had it on the other page?

From
Pizmal

Posted: Fri Oct 15, 2004 6:32 am
by twigletmac
With register_globals off just doing:

Code: Select all

if (!empty($ID)) {
won't work because $ID doesn't exist, to test for the 'ID' variable in the URL, you would have to do:

Code: Select all

if (!empty($_GET['ID'])) {
Mac

Posted: Fri Oct 15, 2004 7:22 am
by Black Unicorn
PHP is case sensitive.
$_GET["ID"] will be empty if the query string has something like
inkrequest.php?id=$row[workorder_id] in it.

Use $_GET["id"] instead.

Posted: Fri Oct 15, 2004 9:19 am
by Pizmal
That would explain why it doesnt work with reg globals off :) Thank you for your help. I was looking through my site and figure if $_server wasnt effect which i kinda knew it wouldnt be that it would have to be somethign with how i carried over the variable.

Once again thanks for showing me the way!

--Pizmal

Posted: Fri Oct 15, 2004 9:38 am
by twigletmac
Just in case, to reiterate what Black Unicorn posted, PHP is case sensitive so $_server is different to $_Server is different to $_SERVER. The last one is the one that you would use to get the predefined server variables e.g. $_SERVER['PHP_SELF'].

Mac