home / blog

Tag Archives: php

Dreamhost php-cgi use different php.ini per directory

The popular gallery webapp still uses dated short PHP open tags <?, this makes it difficult to deploy in a subdirectory of a site that uses XHTML which requires short_open_tag=off to use &lt?xml… headers, leading to the following error. Parse … Continue reading

Posted in geek | Tagged , , , | Leave a comment

Reverse geocode using PHP

function getPostcode($lat, $lng) { $returnValue = NULL; $ch = curl_init(); $url = “http://maps.googleapis.com/maps/api/geocode/json?latlng=${lat},${lng}&sensor=false”; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $result = curl_exec($ch); $json = json_decode($result, TRUE); if (isset($json[‘results’])) { foreach ($json[‘results’] as $result) { foreach ($result[‘address_components’] as $address_component) { $types … Continue reading

Posted in geek | Tagged , | Leave a comment

Fatal error: Call to undefined function curl_init()

If you’re using curl functionality in PHP you’ll need the cURL module installed otherwise you’ll see this error. “Fatal error: Call to undefined function curl_init()” sudo apt-get install php5-curl sudo service apache2 restart

Posted in geek | Tagged , , , | Leave a comment

Enabling PHP system calls

If you’re struggling to enable any of the functions (system, exec, popen etc) by disabling safe mode, then you’re going down the wrong path. You need to change the disabled_functions key in php.ini instead. ; This directive allows you to … Continue reading

Posted in geek | Tagged | Leave a comment

LAMP hello world

Quick start/refresher cheat-sheet on setup of fresh LAMP test server on Ubuntu 9.10. Intended for local development only, no security concerns addressed. Installation apt-get install apache2 libapache2-mod-php5 php5 mysql-server php5-mysql Login as root user to create a dedicated user and … Continue reading

Posted in geek | Tagged , , , | Leave a comment

PHP with apache on Mac OS X

Enable apache server with System Preferences -> Sharing -> Web Sharing -> Enable sudo emacs /etc/apache2/httpd.conf # Comment in the following lines #LoadModule php5_module libexec/apache2/libphp5.so #LoadModule fastcgi_module libexec/apache2/mod_fastcgi.so # Restart apache to pickup config changes sudo /usr/sbin/apachectl restart By default … Continue reading

Posted in geek | Tagged , | Leave a comment