Forum Moderators: coopster
I am having a very strange problem and I am sure someone will be able to assist me.
Simple query as an example :
INSERT INTO category (`id`, `title`) VALUES (NULL,'é\"\')ç(_)(_)è_()\"è()\"') When processing the query on my website, I get this in my table.
é"')ç(_)(_)è_()"è()"à But when I open PHPMYADMIN and type EXACTLY the same query, it works great.
And when I create a test.php file and run the same query, it works fine also.
This is what I have done temporarly but I don't like inserting HTML entities into my database because there are two issues.
Field varchar limit
*******************
As for example, if I limit my title to 100 characters in my database and someone type a text with lot of special characters then the title is trimmed during insertion.
Uppercase
*********
If I want to print my title in uppercase - like strtoupper($title) - then é become É instead of É. Meaning that I need to decode the title, change it to uppercase and encode it again using htmlentities().
Am I wrong when I say that putting HTML entities in the database is not recommanded?
Anyway, I know almost the functions that may used (htmlspecialcharacter, htmlentities, mysql_escape_string, shellcmd, addslahes, magic_quote, etc.)
I 'll try to see what the problem... I suspect there is problem with charset, though both my database and my website are in UTF-8.
As I said, the problem was due to the Collation Unicode Encoding - though both my website and SQL were in UTF-8.
Setting UTF8 in the database by _utf8 in the INSERT statement works
INSERT INTO $tcat (`id`, `title`) VALUES (NULL, _utf8'".$form_title."')";
For advanced reading about Collation Unicode Encoding and UTF-8, go to
[dev.mysql.com...]