Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass '&' through to a web page

Status
Not open for further replies.

bccamp

Technical User
Jan 20, 2005
69
I'm trying to pass a variable with the '&' sign through to a web page to be searched in a db. I don't know what to use to make php understand that it's not two different variables.
ex.

some_com.php?cat=a&b>a&b

Php reads it, of course, as cat=a and another variable b.
I want to use cat to search the mysql for the match to "a&b".

How do I join them or make php see it as one unit or list it on the initial page where it's not looked at as 2 variables?

It wouldn't matter, but my DB that is being searched has more than a few '&' in the titles. Any help would be appreciated.
 
Create a GET-method form with one text input, enter a semicolon into that field, and submit the form.

What appears on the URL of the page to which you submit?


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Try using hex notation:

Code:
some_com.php?cat=a%26b>a%26b

and see if that works.

Hex 26 should be the ampersand, and theoritecally this should pass 'a&b>a&b' as the variable cat.
 
Thanks for the help. As soon as I posted the question, I figured a work-around. I changed my 'cat' value on the page from ?cat=a&b to ?cat=a_b. I then used ereg_replace on the php side to convert it back to 'a&b'.

$value=ereg_replace("_","&",$value);

This allowed the query to search the db in the correct form.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top