Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Modify the code to ensure that any whitespace the user might have inadvertent

ID: 3738971 • Letter: 1

Question

1. Modify the code to ensure that any whitespace the user might have inadvertently entered at the beginning or end of his search term is stripped Ssearchterm S_POST['searchtermD 2. Modify the code to ensure a connection to your MySQL server. @Sdb ('localhost', 'bookorana','bookonama 123', 'books'); 3. Edit the following code to bind the four variables to the four columns returned by the MySQL query Sstmt-> Sisbn, Sauthor, Stitle, Sprice) 4. Use the appropriate MySQL function to close the connection to the Sdb database 5. Modify the code to connect to a MySQL database by using PDO: $db = (Sdsn. Suser,Spass)

Explanation / Answer

1. Modify the code to ensure that any whitespace the user might have inadvertently entered at the
beginning or end of his search term is stripped.

$searchterm="%{$_POST['searchterm']}%";

2) Modify the code to ensure a connection to your MySQL server

$db = new mysqli('localhost', 'bookorama', 'bookorama123', 'books');

3) Edit the following code to bind the four variables to the four columns returned by MySQL query.

$stmt->bind_result($isbn, $author, $title, $price);

4) Use the appropriate MySQL function to close the connection to the $db database.

$db->close();

5) Modify the code to connect a mysql database by using PDO:

$db=new PDO ($dsn,$user,$pass);