LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   PHP: Problems comparing data from a DB with data from http request (http://www.linuxquestions.org/questions/programming-9/php-problems-comparing-data-from-a-db-with-data-from-http-request-662637/)

eantoranz 08-13-2008 09:16 PM

PHP: Problems comparing data from a DB with data from http request
 
Hi!

I'm trying to compare data that's coming from a DB with data from one http request.

When I use plain old ascii data, I have no problem comparing both, however, when I try to use the string "Universidad Pedagógica Nacional", I can't tell when there's a match between the two. Just to see what was going on, I tried to compare the rawurlencode of both strings, and then I noticed that both string are not exacly equal. See what both values would be:

1: Universidad%20Pedag%C3%B3gica%20Nacional
2: Universidad%20Pedag%F3gica%20Nacional

See? The first is from the http request, the second came from the DB. Any ideas how I can avoid it?

Thanks in advance.

chrism01 08-13-2008 09:32 PM

First you need to decide which lang you are going to use internally (English or Spanish), then ensure that any entered data is re-rendered into that lang/alphabet.
Or ensure all data entry uses the same UTF encoding std. Unfortunately, there is more than one UTF encoding avail...
http://en.wikipedia.org/wiki/Compari...code_encodings

eantoranz 08-13-2008 09:56 PM

Thanks for your swift replay, man. I just noticed that I won't have a problem with that, cause the data that will be provided in the http request will be like the data in the DB (just changed the parameter to what the rawurlencode function said it was and then the match happened! Cool! Now I don't have problems with accents:

Look at basically any item from this list:
http://www.dondeestara.net/beta/?lang=es&city=2
http://www.dondeestara.net/beta/?lang=es&city=1
http://www.dondeestara.net/beta/?lang=en&city=4

Every one works... except for the ones that have a ' or " in the name (like McDonald's, or D'Candido)

I guess I'll have to take a closer look at it tomorrow (it's already late at night here so I'm heading to bed... anyway, take a look to see what you can think of).

eantoranz 08-14-2008 07:55 PM

Well, I think I got it solved. I had to use stripslashes before looking for the object.

www.dondeestara.net?lang=es&city=1
www.dondeestara.net?lang=es&city=2
www.dondeestara.net?lang=en&city=4


All times are GMT -5. The time now is 08:40 PM.