MySQL error 1067 on Windows 8 (error 87)

I installed MySQL 5.0 on a Windows 8 machine, everything worked out just fine, but the next day, after a reboot, the MySQL service would not start. The error message was

Could not start the MySQL service on Local Computer.
Error 1067: The process terminated unexpectedly.

I tried a bunch of things, even reinstalling MySQL, but it wouldn’t start anymore.

Looking at the error logs (in the data directory, in my case in C:\Program Files\MySQL\MySQL Server 5.0\data, the file is called server.err), I read

InnoDB: Operating system error number 87 in a file operation.

Thanks to a blog post on websofia.com, I finally managed to get the thing up and running again by adding

innodb_flush_method=normal

to my my.ini. This finally solved it. Thanks Alex!

Check the blog post as it contains some other very useful learnings when dealing with MySQL on Windows.

Share

Facebook user info still available after logging off from facebook through php

For one of my websites, I’ve implemented the Facebook login option, using the Facebook php SDK. Even though working with Facebook SDK’s can be frustrating, as their processes and rules change often, it is an easy way for users to log in.

Everything was working great, until a few months ago. I noticed that when the user clicked the url generated by $facebook->getLogoutUrl, the user was logged out from Facebook (as documented), but I still got the user’s Facebook data using $facebook->getUser();. In other words, my website still showed the user as logged in. I first thought I did something wrong (like forgetting to unset a $_SESSION-variable) but after careful investigation, it turned out to be a Facebook issue.

The $facebook->getUser() documentation states “this method returns the Facebook User ID of the current user, or 0 if there is no logged-in user.” However, after logging out, $facebook->getUser() still gave me the Facebook User ID. Also $facebook->api('/me') still gave me all details. Strangely enough, going to www.facebook.com gave me the Facebook login page, so I was definitely logged out.

After a lot of Googling and testing, I finally could make it work by adding $facebook->destroySession() to the code that is called by clicking $facebook->getLogoutUrl. After a $facebook->destroySession(), $facebook->getUser(); seems to give 0, as it should.

Share

Dealing with UTF-8 text using the PHP mail()-function

On one of my PHP-based websites, users can send mails via a simple text form. I had a problem with special characters in the subject or message body. The webpage has a <meta charset=”utf-8″ />-tag, which causes problems when people enter special characters, like é or € or “smart quotes”. They get sent via the mail()-function and show up like Ã³ or Ã© or â€™.

Deep down in the user comments in the documentation on the mail()-function, I found a small function that solved this easily:

Just use mail_utf8() instead of mail() on a UTF-8 page and a proper UTF-8 mail will be sent out.

Share