Forum Moderators: coopster

Message Too Old, No Replies

Help w/PHP script passing query strings

need conversion for exit.php?url=www.site.com?test1=1&test2=2

         

Juleeeah

7:53 pm on Sep 22, 2003 (gmt 0)

10+ Year Member



I am using a simple PHP script for a redirect. It uses a path like this:

/exit.php?url=www.site.com

However, when the other site has parameters that I also need to include, the script stops working. For instance:

/exit.php?url=www.site.com?other_site_paramenter=test

I know the problem is the 2 question marks... but I can't find a list of codes for the replacement value. In the late 90s I knew this... the? and & characters should resolve to something with %, but I can't remember what. Can anyone help out?

Thanks in advance :)
-Julia

jatar_k

8:40 pm on Sep 22, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld Juleeeah,

Passing an argument with & in the URL [webmasterworld.com]

This thread might be the answer. If not, just ask away.

coopster

9:22 pm on Sep 22, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Juleeeah, you are thinking of the The HTML Coded Character Set [w3.org], but jatar_k is right -- you are going to need to urlencode.

Juleeeah

3:16 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



Thank you. I found a small chart of the escape characters that I need:

[distance-ed.bcc.ctc.edu...]

I think that by replacing? with %3F and & with %26, etc. - the 2nd URL should resolve properly. Those are the codes I was looking for.

Thanks again,
-Julia

coopster

4:08 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



True, but PHP makes it easier for you with the PHP urlencode() function [us3.php.net]. If you're going to use PHP, you might as well use PHP ;)

Juleeeah

4:33 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



Yes, I agree - that function does satisfy my needs. I appreciate the nudge :)