PHP Exif/IFD0 Functions

5th February 2008

The Exif/IFD0 functions in PHP work with images to pull out meta data associated with them. Most image applications and digital cameras will produce an image with a certain amount of meta data present. This is obvious stuff like file size and creation time stamps, but you can also get stuff like copy right notices, camera name, date picture taken and even things like location if the camera was linked to a GPS system. This meta data can be used to sort or categorise images.

MySQL Error Reporting In PHP

4th February 2008

Using MySQL as a database engine in PHP is very powerful, but one thing that can be a pain is trying to debug code. Spotting the difference between a PHP error and a MySQL error can be hard with larger systems.

A good way of debugging MySQL code is by using the mysql_errno() and mysql_error() functions. These functions print off the last error that yuour MySQL server encountered so it can tell you exactly what is wrong with your SQL statements.

Using PHP Sessions To Detect Returning Users

3rd February 2008

To detect a user returning to a web page you can use the built in PHP session manager. At the start of the code you can use the session_start() function to initiate the session, you can then use the $_SESSION global array to store and retrieve information. The session_start() function sends a cookie to the client with a unique code that looks like this

Benchmark PHP Code With microtime()

2nd February 2008

Sometimes is is necessary to see how long your PHP code runs for. This can be done using the following function and examples. This will convert the result of the php function microtime() into a float value.

Procedure For Changing The Directory Of A Wordpress Blog

1st February 2008

For many sites the blog is only part of the site, not the main reason for the site existing. In these cases the blog is kept in the directory /blog or similar. Occasionally (for what ever reason) it might be necessary to change the directory. To that end here is a small walk through of the steps you need to take in order to do this.

Using PHP To Generate CSS

31st January 2008

Generating CSS with PHP has several benefits. For example, you can keep all of your colour declarations as PHP variables so if you need to change any colours it only takes a small edit and not a find/replace operation.

Getting PHP to generate CSS requires just two steps. The first thing to do is to open your CSS file and insert the following line at the top. This tells the browser that the file is CSS.

JavaScript Scrolling Box Marquee Replacement

29th January 2008

Having a Marquee on a web page is a nightmare from an XHTML validation point of view, so here is a neat function that will produce the same effect as a vertical scrolling marquee, that passes XHTML validation, and built entirely from JavaScript and CSS.

Vertical Scrolling

Take the following HTML code. Don't worry about reading it. It is just 7 p tags (2 of which act as spacers) contained within a div tag.

Logging Onto A MySQL Database

28th January 2008

If you have command line access to your MySQL database server you will need to use certain parameters to log in. Most web hosts will not allow you to do this, so you might want to install MySQL into a local computer and give it a go.

To log into mysql you must run the program called mysql with certain parameters. Here is an example.

Flashing JavaScript Text

27th January 2008

Here is a simple function that makes text in a tag fade into one colour slowly before quickly fading back into the original colour. If the background is the same colour as the text then the text will appear to fade in and out.

PHP5 Error Reporting

26th January 2008

PHP has some very nice error reporting features, which can tell you many things about the code that you are trying to execute. This error reporting is always nice to have available when debugging code as it helps you solve many of the common mistakes that occur when creating dynamic web pages.