Tuesday, 31 October 2006

Week 6 - 3-tier and PHP

We now move on to looking at how a web application can be developed using PHP and MySQL. The example we provide is some basic code for a photo album. This includes example code for the basic operations

Powerpoint Slides

see the PHP entry in this Blog for information and resources on PHP

Examples of PHP scripting

Saturday, 28 October 2006

Simple Album code

Here is a very basic photo album application implemented in PHP and MySQL with all sources in this zip file.

There is sample PHP code for doing some of the basic tasks in this application:
  • creating a member
  • editing a members details
  • adding a photograph
  • displaying photos
This implementation is very basic and you should identify shortcomings, select those that you will want to repair or new functionality to be added and then extend this base code (or write your own from scratch) .

I''ve made a few minor improvements to the sample code handed out in class:
  • A few more comments
  • Changed from $_GET[] to $_REQUEST[] as the array from which form data is accessed. This array includes data sent from a form either as method='get' or method='post'. Use get during testing and switch to post if necessary in production
  • dropped the MYSQL_ASSOC parameter - it's not necessary

Friday, 27 October 2006

Group Allocations

Here are the group allocations for the first assessment - if you are not down here and on the course it is very important that you attend the tutorial on the 3rd of November to be assigned a group.

Group A: Michael Wiggins, Phil Neath, James Hanson, Farhan Maswood (4) - Phototurk
Group B: Keir Moffat, Carl Webster, Adam Barnwell (3) - Ticklr
Group C: Craig Sperrings, Alistair Philipps, Mike Cox, Gurdev Singh (4) - Lil Flickr
Group D: Harpal Singh, Tom Piccarilli, Jay Pick, Luke Taylor (4) - Image.com
Group E: Nikki Mackenzie, Ian Wingfield, Fahmida Noor, Nitendra Gurung (4) - Photoshare
Group F: Jessie Owen, Tyra Yu Zhang, Tom Lopez, Gary Herbert (4) - Flipr
Group G: David Wilson, Iain Rose, Nathan Agland, Mathew Tanner (4) - Flickd
Group H: Chris Cutler, Jason Brady, Craig Poole, John Paul Vargheese (4) - Picture Perfect
Group I: Joe Lam, Elspeth Limer, Ady Harold, Charles Lindores (4) - Fickr

Thursday, 26 October 2006

Week 5 - ERM to RDBMS

Conversion of an ERM to a Relational Database using QSEE

Friday, 20 October 2006


MySQL is installed for student use on the host 'shares', a Unix server accessible only from within the UWE domain. The current version is 4.0.13.

Each student has one database, with the same name as their UNIX username. All tables must be created in this database. Login with the UNIX username and original UNIX password. Get it reset by the help desk if you can't recall what this password is.

You can access the database in either of two ways:
  • Using the web client PHPMyAdmin: http://isa.cems.uwe.ac.uk/new/phpmyadmin/
    • This GUI interface allows you to browse, edit, create and modify tables. However, since we are using QSEE to generate code, this will not be so helpful although a file of SQL commands can also be executed.
  • By logging in directly to the server for example, using Putty and starting the SQL command line interpretor (CLI).
    • e.g to start: >mysql - u cjwallac -ppasssword
    • to execute a file of SQL commands use the source command : source 'filename'
  • Table names on the version of MySQL running on the host 'shares' are case sensitive because this a Unix server. Take care when developing on Windows because case is not signicant so code may work on your own machine but not when installed at UWE.
  • The SQL generated from QSEE will cause errors when loaded using PHPMyAdmin due problems with comment lines with no space after --. You must also ensure that there is a use statement at the beginning. To overcome these problems you must edit the generated code. The mysql CLI is not so fussy and thus easier to use.
  • auto_increment is not settable in QSEE so this will need to be set separately. One approach is to define such changes in a separate file of Alter Commands for example:
    • alter table photo
      modify photoid int auto_increment;


PHP links


The current version in CEMS is PHP5.

There are three servers with slighly different PHP configurations.
  • www.cems.uwe.ac.uk - a PHP script will run either on web02 for students or web03 for staff. PHP on these servers has error reporting turned off. For students, www is only accessible if a request has been approved to permit access.
  • isa.cems.uwe.ac.uk - error reporting is turned on. You should use this server for all development. isa is only available within UWE
  • stocks.cems.uwe.ac.uk is an older server and runs PHP4
You can check the PHP configuration: isa, www, stocks

  • Put all php scripts in a suitable subdirectory of your public_html account on the UNIX server (in the nas folder)
  • To execute a php script, use a URL of the form
    • http:isa.uwe.ac.uk/~meonunix/DSAW1/addMember.php
  • Use the 'isa' host for all development.
  • You need a line editor like PFE32 so that when an error references a line number, you can find that line in the editor. (we need a better editor - suggestions?)
  • Beware of the slight time lag between editing a script via Windows and the same changed script being executed on the relevant UNIX server.
  • Use the $_REQUEST array to access both get and post variables. Use method="get" when testing - it's much easier to detect errors if you can see the values being passed from the browser on the command line. You can also bookmark a URL so a test can be repreated without having to enter the data again. You will also need to use 'get' when a deep link is created, for example in the Album code to fetch a a JPEG.
  • You can get a php script to display nicely using a suffix of .phps. This can help spot missing quotes or brackets. In my examples I create a symbolic link in Unix to the .php file itself. Beware of exposing passwords to your MySQL account if you do this - place connection details in a separate file which can be placed above the web accessible pages in public_html.
  • Larry Ullman, PHP and MySQL for Dynamic Web Sites, Peachpit Press ISBN 0321336577
  • Luke Welling and Laura Thomson, PHP and MySQL Web Development, Sams Publishing. ISBN 0672326728
  • Leon Atkinson, Core PHP Programming, Prentice Hall , 2001

Week 4 Abstraction layers

This week we move up the abstraction layers to look at conceptual modelling. In particular we look at Entity-Relationship Modelling (ERM) and the use of a case tool QSEE which we will use. Shortly the emphasis will be on using QSEE to create a Relational database, but at present we will use QSEE to record our understanding of the underlying data structures required to support Flickr.

In the tutorial we will be forming groups to undertake the first coursework. These groups will be selected to get a mixing of backgrounds and technical skills.

To get the basic use of QSEE sorted, you will be using this package to diagram the KML folder description from the lecture.

  • A Folder has a name and contains zero, one or more PlaceMarks and some Styles
  • A Placemark has attributes of :
    • A name
    • A description
    • A position defined by its longitude, latitude and Altitude, each represented by a signed decimal number
  • Each Placemark belongs tojust one Folder
  • A Style defines the appearance of one or more placemarks
    • the symbol to show as a jpeg image
    • the size,
    • the foreground and background colours.
  • Each Placemark has a Style
The QSEE package includes some excellent help files and examples and I have supplemented this with some additional notes. We expect that you will use QSEE to document your understanding of the Flickr application before using it in a model-driven mode to create your own version of Flickr.

Sunday, 15 October 2006

Coursework 1

The specification for the first coursework, a group project, is here and hard-copies were handed out in lectures some weeks ago.

Groups have been created.

Sample PHP code to demonstrate how to do the basic operations is provided, as is guidance on the use of PHP and MySQL in CEMS.

Thursday, 12 October 2006

Week 3 - Logical Data Models and the relational model

Now we move up the layers to look at how data is represented logically, in particular as relations, the basic ideas behind the relational database and MySQL as a typical implementation.

In the tutorial, you will be starting the SQL workbook.

Thursday, 5 October 2006

ITMB lecture

There will be a lecture (video-cast) by Toby Thurston, an Information Architect with IBM on Tuesday 10th October form 16:45 to 18:00 in 1N5.

More infomation is on the flyer.

This should be very relevant to the Multimedia students.


Actually, my mistake, Toby was an IT Architect, which covers the overall system architecture.

Week 2 - Abstraction layers

In week 2 we will be looking at the idea of layers of abstraction. To illustrate the benefits of abstraction, we will spend some time looking at the physical layer and how to delve into it by looking at the Exif data in JPEG files.

In the workshop you will use the hex editor to explore other JPEG files and to unpick MP3 ID3 metadata. Progress on the Flickr review will also be checked.