Page 1 of 1

removing plus sign ( + ) from url

Posted: Sat Jul 25, 2009 11:50 pm
by azhan
Hello guys,

Im having this one problem of removing + sign from url, not the plus sign that generated by browser to separate each word. But plus sign from the content itself.

situation

on page 1, user choose medicine from drop down menu named --> HYDRO+NEOMYCIN (1/8 oz), which have plus sign inside it...

then the page execute to the next page like this... nextpage.php?q=$data

i called back the data by using GET function

$q = $_GET['q'];

but when i wanted to query it from mysql, it return no result...

surprisingly if i paste the name of the medicine directly during query...it does return result..

like this.... $search = mysql_query("SELECT * FROM medicine WHERE name LIKE 'HYDRO+NEOMYCIN (1/8 oz)'");

sadly it doesnt work if i query it by string like this
$search = mysql_query("SELECT * FROM medicine WHERE name LIKE '%$q%'");

I guess it must be sumthing wrong during the transfer via URL...

i try remove the + sign using urldecode, ereg_replace, str_replace...but all doesnt work

do anyone know how to?

thanks
Azhan

Re: removing plus sign ( + ) from url

Posted: Sun Jul 26, 2009 2:43 am
by DaiLaughing
I'm guessing it's because even using an & code introduces a character which GET already uses.

urlencode() seems to be a possible answer. I've not used it but have a look.