mysql 4.1.1 + charset problem + upgrade to mysql 4.1.11

Author Message

Georg Franz

Wednesday 27 April 2005 6:45:07 am

Hi folks,

a bit off topic, but I hope that my post can save some time.

I programmed a small application using php 4.3.x and mysql 4.1.1. I used the latin-1 charset. (Html, DB). A very simple programm, just take input from a textarea field and save it in the DB.

After I finished the application, I did some testing. Problem: If I copied + pasted some text from a simple text editor to the browser and save it in the DB, strange chars appeared in the belonging table. My first thought was that I accidently used utf_encode / decode or a wrong charset ... but everything was okay. I searched many hours to find the problem.

Finally I had the idea to upgrade mysql from 4.1.1 to 4.1.11.

Some upgrading notes:
a) At windows, especially save your mysql-table, it will be overwritten (!) if you use the windows-installer. (Always make a complete backup + dump of all databases - of course.)

Don't forget to save/backup your previous config-files (my.ini / my.cnf) too!

b) common pitfall: Mysql 4.1.x is using the new password system which is not supported by php 4.x. You will not get a connection with php unless you are writing this in your config:
my.ini (windows) or my.cnf (linux):

[mysqld]
...
old_passwords

After upgrading everything worked fine, the problem disappeared.

c) eZ is running fine with mysql 4.1.11 (so far ;-)

Best wishes,
Georg.

--
http://www.schicksal.com Horoskop website which uses eZ Publish since 2004

Bård Farstad

Wednesday 27 April 2005 7:07:57 am

Hi Georg,

thanks for the info.

Was the problem simply a bug in MySQL 4.1.1? Do you know exactly what it was? (wrong character set defined automatically or something like that?)

--bård

Documentation: http://ez.no/doc

Georg Franz

Wednesday 27 April 2005 8:06:35 am

Hi Bård,

I don't really figured out what caused the problem. But I can say what has happened.

If I wrote some "normal" text in the textarea (tried it also with different browsers) everything worked fine. ("This is a test" was saved correctly.) If I copied + pasted some html-code in this textarea and saved it (e.g. from Dreamweaver), the input was saved corrupted. The begin of the html-code was missing, some strange characters appeared etc. I've analyzed the source html-code - no special "strange" character inside.

But the corrupted text looked like a text when you are doing utf8_encode / decode on a string which contains latin-1 + utf-8 coded characters.
(example:
$test = utf8_encode ("ö");
$test .= "ö";)

I didn't use any charset conversion in my program. So my idea was that there is something happening on the way from php to mysql.

The next strange thing is: It happened only at this program. (I tried php 4.3.6 + php 4.3.11 / apache 2 and apache 1.3.x)

So
a) I am happy that my program is working (finally)
b) I am happy that I "only" lost 2 days + 1 day with db upgrade :-)

Best wishes,
Georg.

--
http://www.schicksal.com Horoskop website which uses eZ Publish since 2004

Paul Forsyth

Wednesday 27 April 2005 9:25:56 am

Thanks Georg,

I think i've learnt more about dbs by working through problems than by reading books ;)

But thats true for life i guess!

paul

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.