|
6 May 2003, 19:45
|
#1
|
Rawr rawr
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
|
Apache/PHP problem
A friend of mine has set up his first apache webserver under Windows to try out his first PHP pages. Now, he's having a particular problem when accessing variables from the URL (ie: mypage.bla?var=value).
He gets the following error:
Notice: Undefined variable: show in C:\Program Files\Apache Group\Apache2\htdocs\project\index.php on line 26
LINE 26: if($show == "messageboard")
He's using PHP 4.3.1 (he says PHP4 is mounted on the .php extension).
Does anyone know what this could be?
TY
|
|
|
6 May 2003, 19:58
|
#2
|
Let battle commence
Join Date: Feb 2002
Location: England
Posts: 732
|
its a simple warning to say ur using an undefined variable (i.e. its not been initilised yet) probably cause, if its a query string (the bit after the ?) u've not got Register Globals turned on.
Try accessing the variable using $_GET["show"] instead
Useful things.
$_GET[] is for things on the query string
$_POST[] forms that use the post method
$_COOKIE[] for cookies
__________________
Mit
http://tim.igoe.me.uk - Development Blog
Whats on TV now - UK TV Guide
<Mendosa> mit is a cute cudlly toy that will be in the shops by christmas
<mig-work> ur now my eternal fav pa god
<Squiz> i name thee, Sir Mit
<Zeus> u my friend are a true gamer I knew u were
|
|
|
6 May 2003, 20:11
|
#3
|
Rawr rawr
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
|
I took a look at his php.ini file and he had register_globals indeed off. However, when I told him to put it On, it still refused to load $show. GET_["show"] did work tho. Thanks Mit.
[edit]
Now it also seems to load $show... I guess the server needed some time to load the file, or he didn't restart the server. Sadly I can't look in this guys computer.
[/edit]
|
|
|
6 May 2003, 20:15
|
#4
|
Let battle commence
Join Date: Feb 2002
Location: England
Posts: 732
|
it would have needed a restart to reload the settings etc.
__________________
Mit
http://tim.igoe.me.uk - Development Blog
Whats on TV now - UK TV Guide
<Mendosa> mit is a cute cudlly toy that will be in the shops by christmas
<mig-work> ur now my eternal fav pa god
<Squiz> i name thee, Sir Mit
<Zeus> u my friend are a true gamer I knew u were
|
|
|
6 May 2003, 21:40
|
#5
|
Albatross!
Join Date: Mar 2000
Location: Oslo
Posts: 14
|
ahem
He gets all the notice errors cause he has error_level E_ALL in php.ini
You can turn of notices by changind the error level to E_ALL & ~E_NOTICE
(I prefer to turn off notices on the live site and turn em on at the development site...)
Chriso
__________________
.........................
Any kiddie in school can love like a fool,
But Hating, my boy, is an Art.
-- Ogden Nash
|
|
|
7 May 2003, 10:16
|
#6
|
Forever Delayed
Join Date: Sep 2000
Location: www.netgamers.org
Posts: 1,475
|
Quote:
Originally posted by Structural Integrity
I took a look at his php.ini file and he had register_globals indeed off. However, when I told him to put it On,
|
Go back, and turn it OFF again.
There really is no excuse for being dumb enough to have this turned on.
M.
__________________
Firefly Oper and General l4m3r - "I Do Stuff"
O2 Rip-off campaign
<vampy> plus i hate people ... i despise humanity as a whole
pablissimo "I'm still geting over the fact you just posted a pic of your own vomit"
|
|
|
8 May 2003, 09:33
|
#7
|
Rawr rawr
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
|
Quote:
Originally posted by Mong
Go back, and turn it OFF again.
There really is no excuse for being dumb enough to have this turned on.
M.
|
Why? Is there another way he can automatically approach GET_["show"] as $show ?
|
|
|
8 May 2003, 09:40
|
#8
|
Bitch
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
|
Re: Apache/PHP problem
Quote:
Originally posted by Structural Integrity
Apache2
|
There's your first (unrelated) problem 1.3 > 2 any day of the week and twice on Sundays.
Oh, and you did use $show=$_GET['show'] didn't you?
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
|
|
|
8 May 2003, 10:14
|
#9
|
Let battle commence
Join Date: Feb 2002
Location: England
Posts: 732
|
Re: Re: Apache/PHP problem
Quote:
Originally posted by Gayle29uk
There's your first (unrelated) problem 1.3 > 2 any day of the week and twice on Sundays.
Oh, and you did use $show=$_GET['show'] didn't you?
|
For a start, its nothing to do with Apache Versions, its to do with the version of PHP.
And without turning register globals on, if u place
Code:
$arr = array_merge (&$_ENV,&$_GET,&$_POST,&$_COOKIE,&$_SESSION);
foreach($arr as $key => $value)
${$key} = $value;
at that start of the page, it will simulate register_globals, but its best to use $_GET, $_POST etc.
__________________
Mit
http://tim.igoe.me.uk - Development Blog
Whats on TV now - UK TV Guide
<Mendosa> mit is a cute cudlly toy that will be in the shops by christmas
<mig-work> ur now my eternal fav pa god
<Squiz> i name thee, Sir Mit
<Zeus> u my friend are a true gamer I knew u were
|
|
|
8 May 2003, 10:26
|
#10
|
Bitch
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
|
Re: Re: Re: Apache/PHP problem
Quote:
Originally posted by Mit
For a start, its nothing to do with Apache Versions, its to do with the version of PHP.
|
I did say unrelated, it was merely a general comment on Apache 2.
Quote:
And without turning register globals on, if u place
Code:
$arr = array_merge (&$_ENV,&$_GET,&$_POST,&$_COOKIE,&$_SESSION);
foreach($arr as $key => $value)
${$key} = $value;
at that start of the page, it will simulate register_globals, but its best to use $_GET, $_POST etc.
|
Nice tip, think I may make use of that
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
|
|
|
9 May 2003, 14:25
|
#11
|
Forever Delayed
Join Date: Sep 2000
Location: www.netgamers.org
Posts: 1,475
|
I should point out that register_globals should be turned off, due to its inherent security flaws. Plus it encourages better coding practice.
The PHP site has some info about this.
M.
__________________
Firefly Oper and General l4m3r - "I Do Stuff"
O2 Rip-off campaign
<vampy> plus i hate people ... i despise humanity as a whole
pablissimo "I'm still geting over the fact you just posted a pic of your own vomit"
|
|
|
13 May 2003, 01:21
|
#12
|
Supreme Moron
Join Date: Sep 2001
Location: My Chair (BATH, UK)
Posts: 57
|
Re: Re: Re: Re: Apache/PHP problem
Quote:
Originally posted by idimmu
lazier people just use $_REQUEST[]
which covers all of those bases.
but that defeats the point of not registering globals.
|
and even lazier people use extract() as a quick fix.
__________________
the_angry_angel
- "back and kicking bottom or what?"
- "ah the nali warcow...the cow was a passive creature that just stood there and mooed. so we shot at it."
|
|
|
14 May 2003, 14:54
|
#13
|
/dev/zero Retired Mod
Join Date: May 2000
Posts: 415
|
Theres nothing wrong with extract.
Code:
@extract($array,EXTR_PREFIX_ALL,"cl");
is your daddy
__________________
#linux : Home of Genius
<idimmu> ok i was chained to a desk with this oriental dude
|
|
|
|
All times are GMT +1. The time now is 01:39.
| |