简体   繁体   中英

Search database with special character

How to search the database with special character?

I use this code to as a button

<a href="search.php?search=A & W Restaurants&submit=submit">A & W Restaurants</a>

After that, I use this to search database

$query = mysql_real_escape_string($_GET['search']);

SELECT * FROM table WHERE 1st_column LIKE '%{$query}%'

But the search result show me is empty.

I think is "&" to stop my database query.

any idea on this?

Thanks for advance

i dont think this url "search.php?search=A & W Restaurants" is vaild

please url encode it - A & W Restaurants

try this

SELECT * FROM table WHERE 1st_column='$query'

I don't know about how your setting the search but to get a value colume='to_value' sould work better then like if like is even a select comanned

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM