Forum Moderators: coopster

Message Too Old, No Replies

Storing, Displaying and Searching international characters PHP/MySql

troubles while searching through database

         

darkophoto

1:16 pm on Aug 26, 2007 (gmt 0)

10+ Year Member



Hey all.

I've set up my website for url-rewriting using .htaccess and changed the links to be sort of like this:

www.example.com/catalog/product-name

Product names are of course stored in database, with international characters which display properly (utf-8) for now.
(In some fields I had to use š and ž directly and sometimes stuff like š -- why doesn't š and ž work in all letters?)

But anyway, I got it display fine but now I've got another problem.
Product-name is being passed to code which searches for it in database and displays it's content. It's working excellent, unless it has some international characters.

In which case I got this:
www.example.com/catalog/Za%C5%A1ti%C4%87ene-%C5%BCivotinjske-vrste/

Note the appearing %C5%A1 %C4%87 and %C5%BC
It doesn't even get to the php code, it returns error imidiatelly.

The actual database entry is:
Zaštićene żivotinjske vrste

How can I make a valid reference to this database entry?
And, if possible, a user-friendly one?

Thanks in advance!

[edited by: dreamcatcher at 6:31 pm (utc) on Aug. 26, 2007]
[edit reason] Use example.com, thanks. [/edit]

darkophoto

2:57 pm on Aug 26, 2007 (gmt 0)

10+ Year Member



So, basically, how to handle international characters in URL?
I have to have them in URL because they point directly to database entry. Or, somehow "decode" these codes into what they are in database (after all, they *are* placed from database into URL (encoded) so now I need reverse).

I could implement sort of a "slug" -- separate field in table which would be used as reference in URL (and avoid using strange chars), but that's would be complex since there's already a number of entries in DB.

coopster

8:59 pm on Aug 30, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, darkophoto.

How about html_entity_decode [php.net] and urldecode [php.net], do they help at all?