CSE383-PHP

Objective

The objective of this exercise is to:

  1. Understand database queries
  2. Understand the php programming construct
  3. Write php rest interface

Part #1: Update the lookup table

Exercise
Using phpliteadmin as in the previous lab.
Update the table so that the value field is now a text (string) field
Copy the “Query used to create this table” from the phpliteadmin

Part #2: Update the setLookup rest method

Exercise
Edit the file final.class.php in /var/www/html.
Remove the check for value to be a numeric field Test.
Verify the data was entered correctly by looking in phpliteadmin

Part #3: Create the getLookup rest method

Exercise
Edit the file final.class.php in /var/www/html.

Create the getLookup rest interface
You only need to create the function
I suggest copying and pasting the setLookup routine as a starting point
Arguments (update the function arguments)
date = date field
Returned value
All elements of file that match the requested date
SQL
Call GET_SQL (same calling sequence as EXEC_SQL, but it returns an array of results, keyed by field names)
Query
Reminder. Do NOT copy/paste from word with smartquotes into php (will not work out well)
Make sure you build up the command using the exact same concept as EXEC_SQL in setTemp (but using GET_SQL instead), same argument concept. (every ? needs an appropriate variable to fill it in)
Update the return message with appropriate words for both good and error situations

Reminder

You can look for php errors in the following
If your call to the php doesn’t work or shows a 500 server error, you have a php error.

Check the piece of code you just edited: final.class.php
a. php final.class.php
b. if good - should give NO response
c. if a response - it’s an error
Check the web server output
a. sudo tail /var/log/httpd/error.log