Match the following SQLi functions to their correct function definition
Solution
Answer
mysqli_connect() : Opens a new connection to the MySQL server mysqli_query() : Performs a query against a database.
mysqli_fetch_row() : fetches one row from a result-set and returns it as an enumerated array
mysqli_num_rows() : returns the number of rows in a result set.
Question 2(1 point)
The SQLi function mysqli_query( ) performs a query against a database. What are the 2 compulsory parameter values that must be passed into this function call?
Answer
MySQL connection & SQL query string
Question 3 (1 point)
What is the purpose of the SQLi function mysql_num_rows() ?
Answer: Q3
Returns the number of rows in a result set
Question 4 (1 point)
answer Q4
line 4
Question 5 (1 point)
Answer Q5
line 5
Question 6 (1 point)
For the following PHP scripts, what are the answers for the missing function calls, in the correct order?
if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); exit(); } $sql = "SELECT Lastname, Age FROM Persons ORDER BY Lastname";
if ($result = _____[A2]_________ ($con, $sql)) {
// Fetch one and one row while ($row = mysqli_fetch_row($result)) { printf ("%s (%s)\n", $row[0], $row[1]); }
Simple Login Example I have created this simple Login Example and intentionally leave it as the kind of login that is subject to hacking using SQL injection technique. I will discuss on SQL injection later. XAMP server side (PHP) Database create table users( userid varchar (20) primary key , password varchar (80) not null ); insert the data userid as 'test' and password as '1234' for testing INSERT INTO `users`(`userid`, `password`) VALUES ('test','1234') PHP Step 0: Create db_connect.php ( Refer to Lab2) Step1 :Create a loginTest.php <<< Server Side>>> loginTest.php <?php // check for post data if ( isset ( $_POST [ "id" ])) { $id = $_POST [ 'id' ]; $pw = $_POST [ 'pw' ]; // include db connect class require_once __DIR__ . '/db_connect.php' ; // connecting to db $db = new DB_CONNECT(); $db -> connect (); ...
Comments
Post a Comment