Archive for January, 2006
A new feature of MySQL 5.1 is Events. Similar to a crontab or the 'Task Schedule', it allows you to execute an SQL statement at certain time intervals. The syntax is exceptionally easy to use:
CREATE EVENT [ IF NOT EXISTS ] event_name
ON SCHEDULE schedule
[ ON COMPLETION [ NOT ] PRESERVE ]
[ ENABLED | DISABLED ]
[ COMMENT 'comment' ]
DO sql_statement;
The first thought might be why you would want to run such a query from within MySQL. Running queries at regular intervals is sometimes necessary in large projects, e.g. for general cleanup etc. You can do this from within your chosen scripting language (PHP, Ruby etc), however, this creates another layer of dependancy. If your PHP script can't connect to the MySQL server, then it won't run - storing the event within MySQL overcomes this dependancy.
Continue Reading January 27th, 2006
When uploading files in PHP, its quite common for people to check the MIME type for the file uploaded against an array of allowed mime types. This may seem like common sense, however, its extremely unreliable. The mime type given in the array is the mime type sent by the browser to the script. Most browsers, if not all, determine the mime type based upon the file's extension - which may not reveal the true mime type of the file we are dealing with.
January 19th, 2006
The PHP Extension Community Library (PECL) is a collection of modules/extensions that you can install to enhance your version of PHP. The categories range wildly from Authentication to Image Handling, and from Encryption to XML. However, installation of the PECL libraries can sometimes be a bit tricky for the beginner. There are two main ways to install the PECL libraries. Note that if you installed PHP from an RPM or similar package, you will also need the PHP-devel package as well.
You can view all the PECL modules available at the PECL website. Some useful modules are:
January 19th, 2006
The PHPLondon mailing list have organised the UK's first PHP conference. Details are promising for an interesting day, and I've already booked my ticket! If you plan on going, leave a comment in the blog!
Conference tickets are just £50 each at the moment so make sure you get in there quickly! There is a limited number of seats too!
Speakers:
- Harry Fuecks, author of JPSpan, talking about AJAX and how it sucks.
- Matt Zandstra talking about an object oriented approach at Yahoo.
- Derick Rethans talking about the new Ez Components.
- Christopher Kunz from the Hardened PHP project will scare your pants off.
- Pawel Kozlowski will describe the PHP Pico container and dependency injection
January 11th, 2006
Sometimes, albeit rarely, I've needed to get at the raw POST data in a PHP file. You can of course get the POST data using $_POST, however, this is after PHP has processed it (i.e. magic quotes may have been applied, thus escaping the data). You can access the raw POST information using the following:
You can access the php://input wrapper as if it were a file, and use the Filesystem functions. More information on the PHP wrappers can be found in the PHP Manual.
January 5th, 2006
Here's a nice script I just put together for placing files on DAV-enabled web space, catering for SSL and HTTP authentication. It'll even log the result as presented from an Apache + mod_dav server.
Enjoy!
Continue Reading January 2nd, 2006