Start with thesolutionfrom last week's assignment (NOTE: I prefer that you use my sources as that will make future assignments easier as they all build from on one another) (NOTE: We are working on...

1 answer below »

Start with thesolutionfrom last week's assignment


(NOTE: I prefer that you use my sources as that will make future assignments easier as they all build from on one another)


(NOTE: We are working on the Signature Assignment. Every week we will add bits and pieces to it. So please stay with my solution as we move forward)



Add an exception handler to the previous week's assignment.


· Define a "MySQLI_Exception" class that derives from the base Exception class.


o The purpose of the Exception class is to report MYSQL connection issues


o Put this class in a separate PHP source file.


o In the MySQLI Exception class define your own "__toString" function that includes the exception code, string, filename and line number


o 10 pts


· Include this newly created source file that contains your exception class in both the "blog_user.php" source and the "blog_db_interface.php"source


o You will need to useinclude_once (instead of include)


o 5 pts


· In the "blog_db_interface.php" source file


o Suppress the error message coming from "new mysqli()" by using the "@"


§
$db=@newmysql


o Replace the code that was previously echoing a potential mysqli error


§ You should now "throw" your exception here.


§ The message should be a meaningful string


§ Capture the mysqli_connect_errno() as the code that is passed to the instantiation of your exception object


o 15 pts


· In blog_user.php


o Include a try/catch around all of the code


o Catch your exception in the try


o Include a catch that captures all other exceptions


o echo the exception that is caught


o 15 points


· Test your code


o Go back into bog_db_interface.php and change the code to purposely pass in a bad parameter that will, in turn, cause an exception (a bad user name, a bad password)


o Make sure the changes you made are propagated to every instance where you are connecting to the database


o 15 points


NOTE: In visual source turn off breakpoints on exceptions else you will have trouble stepping through the code (on the left hand side your will see VARIABLES, WATCH, CALL STACK and BREAKPOINT. Expand BREAKPOINTS and not that you can uncheck "Exceptions")

Answered Same DayJul 07, 2022

Answer To: Start with thesolutionfrom last week's assignment (NOTE: I prefer that you use my sources as that...

Salony answered on Jul 08 2022
86 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here