user990664
user990664

Reputation: 37

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

Upvotes: 3

Views: 101

Answers (2)

connec
connec

Reputation: 7421

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] (e.g. & is %26) which is then decoded by the server to its literal character.

Upvotes: 1

jayunit100
jayunit100

Reputation: 17648

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.

Upvotes: 0

Related Questions