LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-13-2008, 09:16 PM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
Question 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.
 
Old 08-13-2008, 09:32 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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
 
Old 08-13-2008, 09:56 PM   #3
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
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).
 
Old 08-14-2008, 07:55 PM   #4
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to receive arbitrary HTTP posted XML data in a php script rstewart Programming 2 03-10-2006 11:36 AM
Writing Request Data to Web Server lucky6969b Programming 1 12-20-2005 10:43 PM
Printing out http request in php abrb220 Programming 1 11-19-2005 02:23 AM
SATA Data Request Error JulesVerne Linux - Hardware 1 01-15-2004 10:41 AM
Problems with php 4.2.1 form-data and hidden variables coea77 Programming 1 10-10-2002 03:24 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration