User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion
Register FAQ Members List Calendar Arcade Today's Posts

Reply
Thread Tools Display Modes
Unread 6 May 2003, 19:45   #1
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
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
Structural Integrity is offline   Reply With Quote
Unread 6 May 2003, 19:58   #2
Mit
Let battle commence
 
Mit's Avatar
 
Join Date: Feb 2002
Location: England
Posts: 732
Mit is a jewel in the roughMit is a jewel in the roughMit is a jewel in the rough
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
Mit is offline   Reply With Quote
Unread 6 May 2003, 20:11   #3
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
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]
Structural Integrity is offline   Reply With Quote
Unread 6 May 2003, 20:15   #4
Mit
Let battle commence
 
Mit's Avatar
 
Join Date: Feb 2002
Location: England
Posts: 732
Mit is a jewel in the roughMit is a jewel in the roughMit is a jewel in the rough
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
Mit is offline   Reply With Quote
Unread 6 May 2003, 21:40   #5
Breed
Albatross!
 
Join Date: Mar 2000
Location: Oslo
Posts: 14
Breed is an unknown quantity at this point
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
Breed is offline   Reply With Quote
Unread 7 May 2003, 10:16   #6
Mong
Forever Delayed
 
Join Date: Sep 2000
Location: www.netgamers.org
Posts: 1,475
Mong is on a distinguished road
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"
Mong is offline   Reply With Quote
Unread 8 May 2003, 09:33   #7
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
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 ?
Structural Integrity is offline   Reply With Quote
Unread 8 May 2003, 09:40   #8
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
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!!!
Gayle29uk is offline   Reply With Quote
Unread 8 May 2003, 10:14   #9
Mit
Let battle commence
 
Mit's Avatar
 
Join Date: Feb 2002
Location: England
Posts: 732
Mit is a jewel in the roughMit is a jewel in the roughMit is a jewel in the rough
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
Mit is offline   Reply With Quote
Unread 8 May 2003, 10:26   #10
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
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!!!
Gayle29uk is offline   Reply With Quote
Unread 9 May 2003, 14:25   #11
Mong
Forever Delayed
 
Join Date: Sep 2000
Location: www.netgamers.org
Posts: 1,475
Mong is on a distinguished road
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"
Mong is offline   Reply With Quote
Unread 13 May 2003, 01:21   #12
the_angry_angel
Supreme Moron
 
Join Date: Sep 2001
Location: My Chair (BATH, UK)
Posts: 57
the_angry_angel is an unknown quantity at this point
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."
the_angry_angel is offline   Reply With Quote
Unread 14 May 2003, 14:54   #13
MT
/dev/zero
Retired Mod
 
MT's Avatar
 
Join Date: May 2000
Posts: 415
MT is an unknown quantity at this point
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
MT is offline   Reply With Quote
Reply



Forum Jump


All times are GMT +1. The time now is 01:39.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018