Project Assignment 12

Database Programming w/ PHP

The CEO of Neo Record Corp knocks on your office door.

"Sooo..." he says and then pauses.

"Yes?" you reply after three minutes of silence.

"Ah... we're going to try to develop a Web-based version of OmniTunes. But nobody on the development team knows anything about the Information Superhighway or The Google or any of that stuff, so I thought I'd ask you. You're a MySpace, right?" he asks.

"Not exactly," you say, "but I do know a little about PHP, and we could use PHP to create a Web-based client. But -- "

"GREAT! I'll tell the sales team right now," and pulls out his pink Blackberry.

"But --"

"Wait wait, shh," he hisses as he wanders off staring and typing into his handheld.

Suckered again, you decide to get started doing a little testing of an OmniTunes client database and PHP.

Create a proof of concept with PHP

This assignment intends to illustrate working with a database on the PHP platform.

Using your music_app database, create PHP scripts that:

  1. Use the PHP MySQL functions to display the name of each genre in the database
  2. Use the PHP MySQL functions to insert a new song, album and artist
  3. Use the provided DB class to display the songs for a particular album
  4. Use the provided DB class to delete a record from the database

Use this zip file to start this assignment.

If you are using the remote development environment, you'll need to:

To migrate the database, use mysqldump to export your database. Use the import tab in phpMyAdmin to import the database.

When using the DB class, don't forget to edit the config file.

Paths and other configuration information are specific for the remote dev env, so if you're working within your own environment you will likely need to modify the shebang declaration to match your php path.

Note: It's not necessary to run these scripts via your Web browser. Just let them write to stdout (see the example file).

To run your php scripts, just ./script_name from the shell prompt. If you get a permission denied message, you didn't set the execute bit: chmod u+x *.php.

Use this syntax guide, the lecture php functions example and the OO example to assist you.

Hints

You can use pico, nano, vi or emacs to edit your php scripts directly in your terminal.

Alternatively, you might want to have an FTP client open, the php script open in your editor of choice, and a terminal window open. You would need to edit the PHP file, upload it to the server, then run it from the terminal and see the output.

Important: I strongly urge you to get started on this assignment asap, and seek help as soon as you run into a problem or are confused about what to do.

Specific Tasks

Save and archive your php scripts. They will be collected with the rest of the project materials at the end of the semester. (tip: don't wait until the end of the semester to work on these scripts, you will receive very limited help, get stressed out, and likely lose some project points.)

To be completed by Monday, April 7