visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
294 experts, 1172 registered users, 1625 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


The DDRK link is back online.
We got a one week service interruption, sorry.
(23-30/01/2010)

Languages :: PHP :: parse_url($REQUEST_URI) doesn't work


By: laputak U.S.A.  Date: 28/09/2004 00:00:00  English  Points: 50 Status: Answered
Quality : Excellent
$url=parse_url($REQUEST_URI);
echo $url[query];

this is what i have used. say if i m viewing <A HREF="http://www.aa.com?show=1">http://www.aa.com?show=1</A>. that should output show=1. However, it works in one web server but not the other one. I have already checked the php manual and it says we don't need to change anything in php.ini in order to use URL funtion. does anyone have any clue about this?
By: VGR Date: 29/09/2004 05:21:00 English  Type : Answer
use $_SERVER['REQUEST_URI']

you could also use SCRIPT_NAME concatenated with QUERY_STRING
By: Kriek Date: 29/09/2004 21:23:00 English  Type : Comment
VGR is correct as usual ;)
By: VGR Date: 29/09/2004 21:29:00 French  Type : Comment
vil flatteur :D
By: RQuadling Date: 29/09/2004 23:57:00 English  Type : Comment
As usual! Pah!
By: RQuadling Date: 29/09/2004 23:58:00 English  Type : Comment
Something to try out too .

<?php phpinfo(); ?>

And then look for REQUEST_URI in the results.

If the server is running an old version of PHP, then you will need to use $HTTP_SERVER_VARS['REQUEST_URI'];

Richard.
By: Kriek Date: 30/09/2004 00:22:00 English  Type : Comment
lol very true
By: laputak Date: 30/09/2004 00:38:00 English  Type : Comment
it works after i m using $_SERVER['REQUEST_URI']. Do u konw y i need to specifally using $_SERVER on one server while i dont need to put that in another server. do u know how to turn that on ?

By: VGR Date: 30/09/2004 00:52:00 English  Type : Comment
in fact, it could depend on PHP version installed
By: RQuadling Date: 30/09/2004 18:37:00 English  Type : Comment
Using the phpinfo(), you can see which one is available.

I would then ...

if (!isset($_SERVER))
{
$_SERVER = $HTTP_SERVER_VARS;
}

which is a cheat, but then you can write code for both old and new versions of PHP. But in truth, you may have more work to do than that.

Ideally, you should have the same version of PHP locally as the ISP. Even if this is old. Unless you are VERY friendly with an ISP, many will rarely update the server as the impact on everyone else on the server is significant.

Richard.

By: RQuadling Date: 30/09/2004 18:37:00 English  Type : Comment
Alternatively, ask if they have a newer server running the latest PHP that you can have your site moved to.
By: VGR Date: 30/09/2004 19:20:00 English  Type : Comment
agree, and it's sadly the same for $_POST[], $_GET[], etc as it is for $_SERVER[]

the best is to drop a page like this on both servers and to show us the top-results (server & PHP versions running)
<?
phpinfo();
?>

Do register to be able to answer

 Add This Article To:
 del.icio.usDel.icio.us  diggDigg  googleGoogle  spurlSpurl
 blinkBlink  wongWong  simpySimpy  yahooY! MyWeb 
EContact
browser fav
page generated in 67.213060 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page