Feb 18
  • english
  • german

I just had a strange error in a piece of PHP code. It should query a MySQL database and render an HTML selectbox out of the result. Sadly, the selectbox had exactly one entry less than the table! This entry was unique - it had an umlaut as first character and that was the clue for me: the encoding!

The database table was encoded in latin1_swedish... and the file was utf8. Initially I thought: well, if I use utf8, I'm quite safe but I was wrong - obviously. Then I used Eclipse and saved the file with iso-8859-1 encoding and hurray: it worked!

What I found confusing about this, was the fact that this very sql statement returned the completely correct result when entered in phpMyAdmin! Seems like the file encoding there was correct rightaway.

Einen Kommentar schreiben