Welcome to WebmasterWorld Guest from 54.166.224.46

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Get Query String

     
4:43 pm on Aug 20, 2002 (gmt 0)

10+ Year Member



How can you get a query string from a link in php?

i.e. abc.php?pic=123.jpg, so query_string contains '123.jpg'?

4:58 pm on Aug 20, 2002 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



This'll do it: parse_url() function [php.net]

The manual is very simple to use and a absolute goldmine of usefull information ;)

Nick

5:16 pm on Aug 20, 2002 (gmt 0)

10+ Year Member



thanks, but this is does not do what I want. I need to get the string from a link in the HTML, this function presupposes you have the URL as a string, I need to get that from the link:

e.g. <a href="getimage.php?name=123.jpg"> and when the user clicks this link, the getimage.php script is able to get the parameter off the link line...

5:19 pm on Aug 20, 2002 (gmt 0)

10+ Year Member



Wouldnt it just be 'echo $pic'? Or are you just wanting to store it again?
5:19 pm on Aug 20, 2002 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Then you have a long painfull journey ahead!

Regular expressions!

Rather you than me pal ;)

Nick

6:35 pm on Aug 20, 2002 (gmt 0)

10+ Year Member



Usually, if you call a PHP script with ?variablename=value, you automatically have a variable called $variablename.
If, however, register_globals is on in php.ini, and it's on by default in newer versions of PHP, you can only get the variable this way: $_GET('variablename') or $HTTP_GET_VARS('variablename') for security reasons.

If you really want the whole query string, which in the example above would be "variablename=value" (NOT just "value"!), you can use getenv($QUERY_STRING), or just $QUERY_STRING, depending on your settings.

6:48 pm on Aug 20, 2002 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



No, you're a little off track: read msg #3

Nick

 

Featured Threads

Hot Threads This Week

Hot Threads This Month