[thelist] PHP encoding &s in a URL

fstorr fffrancis at fstorr.demon.co.uk
Mon Sep 1 12:29:11 CDT 2003


Hi all

This should be simple, but for the life of me...

I've got a MySQL db and am running PHP.  I'm trying to get a link like:

<a href="results?q=D&T">D&T</a>

to pull the required link from my db (the term it should select is D&T).

I've tried encoding that first & in the URL with htmlspecialchars, 
urlencode, htmlentities, but to no avail.  I've also tried not encoding 
it.  I've tried changing the entry into the db from D&T to D&amp;T, but 
that doesn't want to work either.  If I echo out the $_GET, it only 
wants to pass the "D" and nothing else, unless I use urlencode which 
gives me D&T but doesn't get the result from the db (I get nothing as 
opposed to the wrong record).

What's the correct way to encode that sucker?!

Regards

Francis




More information about the thelist mailing list