简体   繁体   中英

Stored special character in Mysql

I have a DB with some product codes, ex: LGE&R , and a pdf of that product LGE&R.

The pdf is echoed into a link that the user clicks to download the pdf , the file is stored on the server with the same name, however the &character is causing the file not to be found , I y think it gets changed.

Any ideas on how to keep it grom changing??

Thanks guys

Sounds like you need to call urlencode on the PDF link before you echo it.

This is because & has a special meaning in URLs, so the URL you think you're requesting, say, files/lge&r.pdf , is probably translated by the server to files/lge , with r.pdf being lost or treated as a GET parameter.

The solution is to 'encode' the URL, replacing URL-meaningful characters (such as &, ?, /, etc.) with %[something] (eg & is %26 ) which is then decoded by the server to its literal character.

http://www.december.com/html/spec/esccodes.html

1) There is a specific escape character or & signs, I would try to replace the URL to use that (%26) In place of &......

If (1) doesn't work then you can simply remove the & and serve the URL up that way, intercept the request, an reroute it on the server.

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