QUESTION 1
(a) Describe how the Web database architecture operates while accessing a PHP script. Illustrate your answer using a diagram.
(b) What is the difference between $message and $message?
(c) Explain each of the following string functions. Illustrate your answer with an example.
(i) strrev()
(ii) explode()
(iii) stristr()
(d) Write a PHP script to read a positive integer, n, from an input text box with the name "txtnum" and to calculate and print the value of 1 + 2 + ... + n.
QUESTION 2
(a) How do you define a constant in PHP?
(b) List the different types of errors in PHP.
(c) Exceptions are used to change the normal flow of a script if a specified error occurs. Describe how the Try, Throw and Catch statements are used to handle an exception.
(d) Outline the differences between mysql_fetch_object() and mysql_fetch_row().
(e) Write PHP script that allows you to fetch information entered in the two text box fields namely: txtStudent for student's name and txtClass for class name and finally appends the information into the file student.dat Your program must also respond by printing a welcome message as follows:
Welcome, x where x is the student name.
QUESTION 3
(a) Show how you can achieve the following in PHP:
(i) a page reloading itself
(ii) causes a web page redirection.
(b) Describe any two different types of arrays as used in PHP programming.
(c) Give two methods that might be used to control sessions in a web based application. Explain the shortcomings of each method.
(d) Write extract codes to demonstrate how PHP allows you to:
(i) create a Session
(ii) retrieve a Session value
(iii) delete a Session.
QUESTION 4
(a) List four benefits while using a relational database such as MySql.
(b) Consider a server with the following settings:
servername: localhost
username: donald
password: jerry
How does PHP allow you to open a connection to a MySQL database, ensuring that the script returns appropriate error message.
(c) Referring to Question 4(b), list the PHP statements that allows you to
(i) create the database named VideoClubDB
(ii) create the database table tblMovie
(iii) add the three fields: MovieName, MovieDirector and MovieType
(d) Referring to Question 4(b) and 4(c), write extract codes to display all the records from the tblMovie table and the results sorted by the MovieName column