CSE383 Homework #13 php/final solution

$25.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (5 votes)

Objective: The objective of this exercise is to:
1. Understand database queries
2. Understand the php programming construct
3. Write php rest interface
Submit: screenshots, your html file and a link to your web page
You may discuss this with your fellow students or the instructor.
Name:
Part #1: Update the lookup table
Estimated time: 15 minutes
Exercise:
• Using phpliteadmin as in the previous lab.
• Update the table so that the value field is now a text (string) field
o Copy the “Query used to create this table” from the phpliteadmin
Part #2: Update the setLookup rest method
Estimated time: 15 minutes
Exercise:
Edit the file final.class.php in /var/www/html.
Remove the check for value to be a numeric field
Test.
http://id.aws.csi.miamioh.edu/final.php?method=setLookup&location=45056&sensor=
web&value=test+12345 (replace id with yours)
Verify the data was entered correctly by looking in phpliteadmin
CSE383 Homework #13 php/final
Page 2 of 4
Part #3: Create the getLookup rest method
Estimated time: 15-30 minutes
Exercise:
Edit the file final.class.php in /var/www/html.
• Create the getLookup rest interface
o You only need to create the function
o I suggest copying and pasting the setLookup routine as a starting point
o Arguments (update the function arguments)
§ date = date field
o Returned value
§ All elements of file that match the requested date
o SQL
§ Call GET_SQL (same calling sequence as EXEC_SQL, but it returns
an array of results, keyed by field names)
o Query
§ $retData[“result”] = GET_SQL(“select * from
lookup where date like ? order by date”, $date .
“%”);
§ 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
Test it by querying
http://id.aws.csi.miamioh.edu/final.php?method=getLookup&date=YYYY-MM-DD
(replace id with your id, YYYY-MM-DD with today’s date)
Show screengrab
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.
1. Check the piece of code you just edited: final.class.php
a. php final.class.php
CSE383 Homework #13 php/final
Page 3 of 4
b. if good – should give NO response
c. if a response – it’s an error
2. Check the web server output
a. sudo tail /var/log/httpd/error.log
CSE383 Homework #13 php/final
Page 4 of 4
SUBMIT:
• Screenshot
o Updated query to create table showing value is text (string)
o Some verification that your rest insert from step2 worked
o getLookup (must include web address and good json response)
• php code
o final.class.php