--- Duncan <[EMAIL PROTECTED]> wrote:
> The only problem is that if there are no arguments in the URL already I 
> get the following:
> http://localhost/dir_to_my_script/test.php?&arg1=1&arg2=2
> notice the "?&" bit.

Rather than trying to see whether this might work on most browser, you
should try to make it right.

When constructing a query string, all you need to do is delimit pairs with
an ampersand:

var1=val1&var2=val2&var3=val3

Don't write your logic in such a way that you construct a string and
always prefix every new addition with an ampersand. This is what leads to
problems like you are experiencing. It's the wrong approach, even though
it can be fixed by distinguishing between the first pair and all others.

In PHP, constructing a proper query string is painfully easy, thanks to
things like implode() and all of the array functions. Once you have a
proper query string, you simply prefix it with a question mark prior to
appending it to the rest of the URL. Just keep in mind that fragments go
at the end.

Hope that helps.

Chris

=====
My Blog
     http://shiflett.org/
HTTP Developer's Handbook
     http://httphandbook.org/
RAMP Training Courses
     http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to