Another lousy PHP/MySQL /charset issue...

We had this quite interesting situation at work today: I export an UTF-8 MySQL database into an UTF_8 SQL file. I *binary* FTP the file over to him. He plays the SQL in PHPmyAdmin all configured for UTF-8. He then checks the data in PHPmyAdmin: special chars display right under an UTF-8 page encoding. He checks under the command line: the DB contents seem to be UTF-8 encoded too...

Now he goes to our app, pulls out some data... and gets a special chars mess... although the html page is displayed as UTF-8. If we force the display to Latin-1, the special chars display correctly again.

The reason for this is that there is actuallly a charset translation taking place between the mysql client (which is PHP here) and the mysql server.

We found we could fix this by editing my.cnf and specifying the following:

# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=utf8

...instead of the latin-1 he had there for some obscure reason.

However, there must be a more explicit way to have PHP retrieve the mysql data as UTF-8, even though we could not find that in mysql_connect() or somethig alike.

Guess, we'll have to investigate the PhpMyAdmin code and see how those guys do it. Btw, this reminds me of a conference by Rasmus Lerdorf where he said the code for PhpMyAdmin was pretty clean and should be studied. Yep, we definitely gotta do that! ;)

Understanding marketing

I received the following in a spam, but I thought it was an interesting image:

You see a fabulous girl/guy at a party. You approach them and say, "I'm fantastic in bed." That's Direct Marketing.

You're at a party with a bunch of friends and see a fabulous girl/guy. You have one of your friends approach them, point at you and say, "She's/He's fantastic in bed." That's Advertising.

You see a fabulous girl/guy at a party. You approach them to get their telephone number. The next day you call and say, "Hi, I'm fantastic in bed." That's Telemarketing.

You're at a party and see a fabulous girl/guy. You get up, straighten your clothes, walk up and pour them a drink. You open the door, pick up their bag after it drops, offer them a ride, and then say, "By the way, I'm fantastic in bed." That's Public Relations.

You're at a party and see a fabulous girl/guy. They walk up to you and say, "I hear you're fantastic in bed." That's Brand Recognition.

Using PHP 4.3.8 with MySQL 4.1

Running an app under PHP 4.3.8 and trying to connect to a MySQL 4.1 database can be pretty frustrating. By default it gives you a message like this:

"Client does not support authentication protocol requested by server; consider upgrading MySQL client".

The problem is that by default PHP's MySQL module is compiled with an older MySQL client library. MySQL has a manual page about this.

I use the OLD_PASSWORD method. I connect to MySQL under root with MySQL Query Browser and I issue the following command:

set password for 'demouser' = old_password('demopass');

Installing & Securing Windows XP (is a tedious task...)

Moving in is such a boring thing to do. Almost as much as moving out. You waste time reinstalling everything you had before, but in different places. You also realize some items don't fit their purpose anymore or don't fit into your new place at all... |-|

I was already feeling bored about this when I crashed my PC, just to make it complete! >:(

Yeah yeah I hear you thinking... a backup saves the day (actually the month), right? I actually had a pretty decent backup... and did not loose any personal data. It's just that reinstalling the whole system & apps is such a pain (no, I had no 'disk image' backup) that I decided I would make the most out of it by switching to XP as a replacement to my aging W2K... That's where it started to hurt! XX(

Actually, I had an XP CD+license available from another PC where I had not installed it... The only problem is that CD was 3 years old. The original flavor of XP.

When you install a 3 years old Microsoft OS, the first thing you gotta do is a comprehensive Windows Update and virtually redownload all the files in a newer version, right? That was my plan...

Read more »

Blog = Tamagotchi ?

Corante [broken link] makes a wise point comparing blogs to tamagotchis:

If you don’t feed them, they die. If you don’t clear up their crap - comment spam, for example - they die. They’re more fun when there are other bloggers to play with, just like the new IR connected Tamagotchi are allegedly more fun because your little virtual pet can now interact with other little virtual pets.

One thing I’d like to add though: many people tend to overfeed their blog by posting just as much as they can find time to! Though I’ve never owned a Tamagotchi, I’m pretty sure they die if your overfeed them. So when will bloggers realize that posting 10 times a day will kill their blog?

I don’t think the average blogger can come up with more than one, maybe two, constructive, original and/or interesting ideas a day. Posting more will only dilute your interesting posts in an ocean of ordinary posts and readers will eventually unsubscribe because they don’t have the time to – or just get bored by – reading all that irrelevant stuff…

I don’t even know why I’m suggesting this since virtually all bloggers tend to consider themselves above average anyway!


Something pretty much unrelated, but I must say Corante also got this “shower lucidity” thing sooo right:

Often thinking requires quietude, physical exercise or doing some non-cerebral task. The shower, for example, is a great place for a good think, but opportunities to take a quick shower in the workplace are, well, limited. This is one of the problems that arises when the creative clashes with the corporate - the way that the creative mind functions is often at odds with the work ethic, not to mention environment, of many companies.