Jump to content


Photo

$PHP_SELF


  • Please log in to reply
3 replies to this topic

#1 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 27 August 2006 - 07:59 PM

I just recently moved to a different server. When i use the variable $PHP_SELF on the new server, it is coming up with the direct page rather than including the GET info. For example if the url is: www.blahblah.com/page.php?id=100, $PHP_SELF (if echoed) will be just www.blahblah.com/page.php.

I was wondering if there is an alternative, or a fix for this? and if any could tell me why it's happening that would be cool too.

Any help appreciated.

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 27 August 2006 - 08:09 PM

Sounds like a register_globals setting difference.  Try $_SERVER['PHP_SELF'] instead.
Legend has it that reading the manual never killed anyone.
My site

#3 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 27 August 2006 - 08:15 PM

That gives the same result. I'm gonna send a message to my host and see if they know what is wrong.

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 27 August 2006 - 09:35 PM

Use $_SERVER['QUERY_STRING'] to get the bit after the ? in the url. PHP_SELF only gets the relative path to the file, it doesnt include the query string. So use this:

[code=php:0]$url = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];[/url]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users