Hi, I am having more troubles with my site. I have a job site, and when people search for jobs or a city with two words (like security guard, or new york), the results don't come out right. For example, it will search for security and guard separately, just as it would with new, and then york. So the url comes out like this: http :// ... ... com / ... /security+guard...new+york... instead of this: http :// ... ... com / ... /security%2Bguard...new%2Byork. Does any1 know how i can fix this and make it look like the second one. I can also show or paste (it here) the php results file if you think u can help. Thanks........
use str_replace function before you pass the search string to search result processing page or submitting the form. See a sample code below. $signs = array("+", " "); $words = array("%2B", "%20"); $searchtext = "security guard+new york"; $change = str_replace($signs, $words, $searchtext); Print $change; Code (markup): Now use the $change to pass the search text value. Hope this helps!
This is due to them entering a space and forms converting the spaces to +. If they enter New+York then it will indeed put New%2BYork. If you want to do it with php use urlencode()
I don't know PHP, but this regex will work: s/\+/\%2B/g; Code (markup): I'm not sure how it works in PHP, but in Perl, you just need to use the variable name like this: $var = "http://www.example.com/?new+york+haircut"; $var =~ s/\+/\%2B/g; Result = http://www.example.com/?new+york+haircut It would be the same if the search query were its own variable (instead of the entire URL).