Category ‘PHP’ (page 2)

From MySQL to HTML with PHP and XML

Wednesday, 21.01.2009.

In my post "From MySQL to XML with PHP", I described how to generate XML from the MySQL database. Instead of printing out XML, generated XML can be buffered and transformed with XSL to the HTML. Maybe it sounds complicated for a simple process of displaying MySQL data on the WEB page. But if you set a WEB architecture this way, you will have a separated presentation layer from the database and business logic.

2 responses so far

Write to a log file with PHP

Wednesday, 14.01.2009.

As you certainly know, PHP can be used for command line scripting too. In my case, I caught myself writing log PHP function many times so I finally decided to write Logging PHP class. After Logging class initialization, first call of lwrite method will open log file for writing. Log file will be closed implicitly when PHP script ends.

15 responses so far

From MySQL to XML with PHP

Wednesday, 07.01.2009.

PHP XML generator can be written in less then 100 lines. In this example, data from the MySQL database are converted to the XML. PHP function sql2xml has an optional second parameter to describe the XML hierarchy, while first parameter is SQL query. Second parameter has the form of integers separated by commas.

8 responses so far

PHP Web server monitor

Monday, 05.01.2009.

With this simple PHP script, you'll be able to monitor the availability of Web servers. Write a list of URLs to monitor and run the script from cron. If a site becomes unavailable, monitor PHP script will generate alert and send e-mail to the default e-mail address. Monitor script is also able to send e-mail message to the various e-mail address (e-mail address per URL).

4 responses so far

Resize images with PHP script

Wednesday, 15.10.2008.

Did you ever try to resize many images at once? I did, and I wrote PHP script for that purpose. Anyway, after I selected few images from my photo album, I realized that every image was about 500KB and resolution of 1600x1200. This seems too big. Images should be smaller and lighter for upload.

5 responses so far