Closed Thread Icon

Topic awaiting preservation: PHP_Self is undefined variable?? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12732" title="Pages that link to Topic awaiting preservation: PHP_Self is undefined variable?? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: PHP_Self is undefined variable?? <span class="small">(Page 1 of 1)</span>\

 
H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 05-13-2003 01:57

Hi all, my webhost recently upgraded from php 4.1 to 4.3, before this all my scripts were working perfectly. Now i am having problems with some undefined variables! in particular $PHP_Self which is supposed to return the current php file name.

Anyone have an ideas or know why this happens? Please help!.

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 05-13-2003 02:00

H][RO: They changed a few things around (not very helpful I agree) so try:

$_SERVER['PHP_SELF']

See:
www.php.net/manual/en/reserved.variables.php

___________________
Emps

FAQs: Emperor

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 05-13-2003 02:12

Thanks Emp, appreciate it. Also it wont pull the variables from the url, like Myfile.php?thisVariable=5

I used to declard $thisVariable as global then i could use it, but now its not working =(, ill have a read of what u posted and hopefully its in there.

Its a bit annoying i thought PHP would keep it the same thru versions =(, i guess it had to be done maybe..

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 05-13-2003 02:16

They've been trying to phase out the conversion of GET variables for a while for security purposes.

All variables in the URL Should be available as

$_GET['varName']

Your best thing to do is use this to set a local variable

$varName = $_GET['varName'];

While this is an extra step it's actually a good practice.



.:[ Never resist a perfect moment ]:.

[This message has been edited by bitdamaged (edited 05-13-2003).]

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 05-13-2003 02:20

=( Thanks guys, is there anything i have to do to make these available? Whenever i do any of the above all i get is "Undefined Index".. Its gonna be one of those days =(...

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 05-13-2003 02:24

I just noticed my PHP_Info file of my webhost has register_globals set to off, could this be the reason why these arent working?

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 05-13-2003 02:57

Ok that wasnt the problem as i read on =/, i figured it out thanks for your help all, much appreciated. I was getting an error but it was still working, because the variable didnt exist the first time the php ran. Silly error on my part hehe.

Thanks again all.

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 05-14-2003 14:43

As far as I know though such variables are case-sensitive...so PHP_Self won't work where as PHP_SELF will...as well, it is an auto-global, so register_globals doesn't need ot be on...if you do turn it on, that means you have to difne all your normal auto_globals at the start of each script.

« BackwardsOnwards »

Show Forum Drop Down Menu