[SOLVED] $_server array (registered global)

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
Pizmal
Forum Newbie
Posts: 19
Joined: Wed Jul 14, 2004 7:43 pm
Location: USA

$_server array (registered global)

Post by Pizmal »

Is the $_Server array blocked if the registered_globals set to off?

--Pizml
LostMyLove
Forum Newbie
Posts: 20
Joined: Mon Sep 27, 2004 12:20 pm

Post by LostMyLove »

no
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

More info: [php_man]register_globals[/php_man]
Pizmal
Forum Newbie
Posts: 19
Joined: Wed Jul 14, 2004 7:43 pm
Location: USA

Post 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
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

post your code here
ps : how the get is coded?
Pizmal
Forum Newbie
Posts: 19
Joined: Wed Jul 14, 2004 7:43 pm
Location: USA

Post 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>";
}
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

How do you retrieve the value from the URL?

Mac
Pizmal
Forum Newbie
Posts: 19
Joined: Wed Jul 14, 2004 7:43 pm
Location: USA

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Black Unicorn
Forum Commoner
Posts: 48
Joined: Mon Jun 16, 2003 9:19 am
Location: United Kingdom

Post 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.
Pizmal
Forum Newbie
Posts: 19
Joined: Wed Jul 14, 2004 7:43 pm
Location: USA

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply