Custom error pages in Kohana v3.x

Wojtek on 404, 500, custom, error, exception, kohana, PHP · · Comments · 2 min read

Kohana framework displays really nice and descriptive error messages, for a development environment that is. For production, obviously no error reports should be shown to the user. Instead we should display a pretty "404 Not Found" page, or some other error page. Creating those custom error pages in Kohana v3.x can be a real pain in the... Read more »

Hot off the workshop vol. 1

Wojtek on CSS, Facebook, HTML, JavaScript, MySQL, PHP · · Comments · 1 min read

Just launched. TK Maxx and Red Nose Day campaign applications. Facebook quiz Fun quiz to find out your perfect Red Nose Day t-shirt. View site Website application Upload you photo with Flash uploader, resize it and pan it around with JavaScript then save your results with PHP. View site... Read more »

Get live exchange rates in PHP

Wojtek on currency, PHP, Yahoo · · Comments · 1 min read

Update: Yahoo has since closed down this service. Below script will no longer work. A very simple PHP script to get almost live currency exchange rates from Yahoo Finance. I’m saying "almost" as as far as I know Yahoo updates it with some minor delay. $from = 'GBP'; $to = 'USD'; $url = 'http://finance.yahoo.com/d/quotes.csv?... Read more »

Handling responses from PHP's cURL

Wojtek on cURL, PHP, response · · Comments · 1 min read

Recently I had a small problem with cURL. The request was supposed to return only JSON data to use in my app. I wrote the following: $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://somedomain.com/api/123'); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_exec($curl); $status... Read more »

PDO rowCount() not working in PHP 5.1.6

Wojtek on bug, MySQL, PDO, PHP, rowcount · · Comments · 2 min read

The bug If you’re running PHP 5.1.6 and just started using PDO for your database connection, it’s likely you’ll run into quite an annoying bug. Lets test a simple query partly taken from PHP documentation. $calories = 150; $colour = 'red'; $sth = $myPDO->prepare('SELECT name, colour, calories FROM fruit WHERE calories < :calories AND colour... Read more »

PHP session handling with memcache

Wojtek on memcache, PHP, session · · Comments · 1 min read

In last two posts I described how to install memcached daemon and memcache extension for PHP. Today I'll show you how to configure your PHP to use memcache to handle sessions. One thing I should mention is that when installing memcache you should answer yes when asked 1. Enable memcache session handler support? : yes First of all, lets start two... Read more »

How to run memcache in PHP

Wojtek on CentOS, Linux, memcache, PHP · · Comments · 1 min read

After installing memcached daemon, we have to install memcache PHP extension. yum install php-pecl-memcache or apt-get install php5-memcache If above is not an option try below method. pecl install memcache After successful installation add memcache.so extension to your php.ini file. vim /etc/php.ini Add this line: extension=memcache.so Restart web server service httpd restart Test out... Read more »

PHP summer time off

Wojtek on PHP · · Comments · 1 min read

Problem PHP has a bug with applying summertime in some timezones. If you’ve set correct timezone in your php.ini file and running still gives you wrong time its quite possible that you’ve just stumbled upon this bug. Solution To correct this you need to install new timezone file. Run below command on your server: pecl install timezonedb... Read more »

MySQL PHP PDO error in xampp

Wojtek on MySQL, PDO, PHP, xampp, Windows · · Comments · 1 min read

If your PDO scripts are crashing Apache after installing xampp 1.7 for windows all you need to do is: download this package http://windows.php.net/downloads/releases/php-5.2.11-nts-Win32-VC6-x86.zip" unzip copy libmysql.dll into xampp\apache\bin and xampp\php restart apache All should be good now.... Read more »