» Currently browsing: Scripts


Execute a MySQL query and return the results as an array with error reporting

December 10th, 2007 at » Comments (0)

This function combines the use of three functions, two of which have been described on later posts.
Connect to a MySQL database using php with error reporting
Displaying array contents in an easy to use format using php
What makes this php query function different from most is the error reporting.  If a error does occur with your […]



Displaying array contents in an easy to use format using php

November 10th, 2007 at » Comments (0)

This function displays the contents of any array in a nicely formatted display.
It combines the <pre> </pre> and the print_r function into one making it easy to use and the displayed results easier to understand.
The function uses one input:
$array - the array variable to be displayed
This is a great function for testing and debugging during developing […]



Connect to a MySQL database using php with error reporting

October 10th, 2007 at » Comments (0)

This function allows you to connect to a MySQL database server and connect to the database in use.
This functionality has been covered many times on the web but i feel adequate error reporting has been left out of most connection scripts.
The function uses 4 inputs:
$hostname - usually “localhost” or the IP address of your database server
$username - […]



Create a file on your server using php

September 9th, 2007 at » Comments (0)

This function allows you to save a file (with correct folder permissions) on your web server or web site with any content you choose.  This is ideal for adding pages dynamically to your site or for error reporting.
The function uses two inputs:
$location - the file location including the file name and extension e.g. “folder/file.html”
$content - […]



PHP and MySQL - Database backup and table tab delimited download

August 10th, 2007 at » Comments (0)

This set of functions allows for a copy of your mySQL database to be saved onto your server in a tab delimited file format ready for download.
I have chosen tab delimited format because of its universal use with other programs and applications.  Once saved onto your local machine you can open it with programs like […]



PHP - calculate days or nights from two dates using php

July 5th, 2007 at » Comments (0)

This function returns the difference of two dates in whole days.  This is great for such uses as hotel calendars to work out how many nights someone would be staying or to give a count down to a specified date.
The input needs two dates; the start ($Date1) and finish ($Date2). 
 This function uses the php mktime function.
The date input is yyyy/mm/dd […]