PHP/MySQL - Special characters in URLs. How to avoid?

Posted by RC on Stack Overflow See other posts from Stack Overflow or by RC
Published on 2010-04-03T17:55:04Z Indexed on 2010/04/03 18:03 UTC
Read the original article Hit count: 218

Filed under:
|
|

Hey everyone,

My database contains information extracted from an external feed. In this raw text feed, the following text is used in place of special characters:

& - &
' - &39;
é - é

I extract some of this text to form URLs. For example, a URL that I construct from data containing these characters might look like this:

http://url.com/search/?brand=Franklin&Hédgson's

I use the GET variables in this URL to construct further lookups, which leads to a couple of specific problems:

  1. The é and ' characters are sent back to MySQL as they appear, and so they don't trigger any results (because the characters take the full HTML form in the database text).

  2. The & within the URL separates the variable, and the GET returns only Franklin, when it should return the whole string.

Are there any straightforward ways of dealing with this?

Thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql