homepage Welcome to WebmasterWorld Guest from 54.197.147.90
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Get Query String
scorpion




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

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'?

 

Nick_W




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

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

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

Nick

scorpion




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

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...

Knowles




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

Wouldnt it just be 'echo $pic'? Or are you just wanting to store it again?

Nick_W




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

Then you have a long painfull journey ahead!

Regular expressions!

Rather you than me pal ;)

Nick

c3oc3o




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

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.

Nick_W




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

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

Nick

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved