[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

GET search query won't work with & in the parameter

Posted on 2010-03-30
3
Medium Priority
?
296 Views
Last Modified: 2013-12-12
Hi,

I've got a problem where if someone searches something like O&O, the query string is formed like this ?search=O&O but the ampersand tells GET that it's a new variable... How do I transfer an ampersand via GET?

Thanks.
0
Comment
Question by:i-CONICA
3 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 1000 total points
ID: 29119734
Form the query string by changing all instances of & to &. This could be done, for example, by using htmlspecialchars().
0
 
LVL 6

Expert Comment

by:jameso99
ID: 29120001
Perhaps on your $_GET['query'] you could use a str_replace()

$var = str_replace("&", "&amp", $_GET['query']);

or maybe putting it in an escape sequence, but I'm not sure how PHP would handle this:
$var = str_replace("&", "\&", $_GET['query']);
0
 
LVL 6

Author Closing Comment

by:i-CONICA
ID: 31709101
Spot on. Thanks.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

590 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question