Php / url-encoding

software development

#1

I am using php to load a text file in part of one of our sites. The http request I make is URL
encoded - but the php is messing up the & (which becomes &) on one of our domains,
but not another.

I have two identitical folders:
blankmosseri.com/
staging.blankmosseri.com/inhouse/blankmosseri/

Both domains are supposedly running PHP 5.1.2

but…

blankmosseri.com/include/getText.php?file=../content/02 WORK/01%
20ARCHITECTURE & SOCIETY/archsoc.txt

is returning an error and

staging.blankmosseri.com/inhouse/blankmosseri/include/getText.php?file=../conten t%
2F02 WORK/01 ARCHITECTURE & SOCIETY/archsoc.txt

is not.

This is very strange. The file content/02 WORK/01 ARCHITECTURE & SOCIETY/archsoc.txt
exists in both directories and include/getText.php is exactly the same.

Please help as soon as you can,
Adam Mosseri


#2

Dunno, but I can tell you that you need to URL encode everything. Run your string through urlencode() before sending them to the query string.

It’ll convert & to it’s % equivalent which will in turn prevent PHP from thinking it’s a query seperator.


yerba# rm -rf /etc
yerba#