Category Archives: PHP

Running OpenX under IIS with PHP 5.3 – date_default_timezone_get errors

I run OpenX (an open source ad serving platform) under IIS and PHP …. but after upgrading to PHP 5.3 noticed the following error appearing in the PHP error logs file (c:\windows\temp\php-errors.log by default).


PHP Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/London' for '1.0/DST' instead in C:\inetpub\wwwroot\openx-2.8.5\www\delivery\spc.php on line 191

The solution to make this error go away is simply to specify a default timezone in the php.ini configuration file. In my case this looked like:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "Europe/London"

PHP 5.3 and IIS 7 – beware of MySQL issues with IPv6

I’ll keep this short and sweet as it’s covered in depth elsewhere. After installing PHP 5.3 suddenly my website stopped working – but instead of throwing errors, it simply sat there and eventually timed out (with no error). Turns out there are issues with both PHP and MySQL around IPv6. The most common solution is “turn off IPv6 support” – not a reassuring answer.

On the PHP front, the issue seems to be around fsockopen which works fine in 5.3.0 but not in 5.3.2. The major issue for most people though is that the MySQL driver doesn’t properly support IPv6 if you’re using a hostname (such as localhost) to connect instead of an IP address, particularly when localhost resolves to “::1″.

I’m not sure what changed in PHP 5.3.2 to bring this to the surface, but the solution is either to switch to using an IP address, for which there are other good reasons to do so, or modify your hosts file (c:\windows\system32\drivers\etc) and change the line the starts with “::1 localhost” to “#::1 localhost”.

Hope this helps someone!