Connecting to a Database using PHP (Part 2)

Quiz
•
Computers
•
Professional Development
•
Hard
JX Chow
Used 2+ times
FREE Resource
9 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The aim of this code is to connect to a Database. Replace the COMMAND_A with the correct command.
mysqli_connect_error
mysqli_query
mysqli_connect
mysqli_fetch_row
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The aim of this code is to connect to a Database. Replace the COMMAND_B with the correct command.
mysqli_connect_error
mysqli_query
mysqli_connect
mysqli_fetch_row
3.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
You have created the following user for your MySQL database located on "localhost"
Which of the following commands will connect successfully?
mysqli_connect(
"newuser",
"123",
"localhost",
"dbstudents");
mysqli_connect(
"localhost",
"newuser",
"123",
"dbstudents");
mysqli_connect(
"localhost",
"dbstudents",
"newuser",
"123");
mysqli_connect(
"localhost",
"newuser",
"123");
4.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
The result of the mysqli_connect() function is very useful.
What can you use $result to do?
Check if result is FALSE:
if ($result == FALSE)
Check if the connection is successful:
if ($result == FALSE)
Execute a SQL query:
mysqli_query
($result, $sql)
Get the number of results in a SQL query:
mysqli_num_rows
($result)
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Why is it important to have this line of code?
include_once "1_Connect_DB.php";
It includes the code from another PHP file which connects to the database
It includes the code from another PHP file which creates a new database
It includes the code from another PHP file which enables the code to run error-free
It includes the code from another PHP file which allows
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the following code do?
$result = mysqli_query($A, $B);
It creates a new query connection to the database to get a result
It makes use of PHP to get a result from the database
It makes use of a query to the database to get a result
It makes use of a database connection to execute an SQL statement
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What should be the variable $A?
$result = mysqli_query($A, $B);
*HINT: it was created using the mysqli_connect command
$A should be the method you wish to connect to the database
$A should be the database connection
$A should be the SQL statement that you want to execute
$A should be the results of the SQL query that you want to execute
8.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The table shows the results of the query to the database.
echo mysqli_num_rows($result);
What is the result of the code above?
1
2
3
4
9.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the result of the following code?
while ($row = mysqli_fetch_assoc($result)) {
echo $row["Taste"];
echo "<br>";
}
Sour
Sweet
Bitter
1
2
3
Apple
Orange
Bittergourd
1 Apple Sour
2 Orange Sweet
3 Bittergourd Bitter
Similar Resources on Wayground
10 questions
GraphQL: DAY 1

Quiz
•
Professional Development
8 questions
ITF - Quiz 4.7 - Using a Search Engine

Quiz
•
Professional Development
11 questions
CCL Coding Standards

Quiz
•
Professional Development
11 questions
5. Echo - Query And ORM

Quiz
•
Professional Development
9 questions
Connecting to a Database using PHP

Quiz
•
Professional Development
10 questions
SQL Database - Basic

Quiz
•
Professional Development
10 questions
Kuis Oracle Database

Quiz
•
Professional Development
10 questions
programowanie w php

Quiz
•
Professional Development
Popular Resources on Wayground
11 questions
Hallway & Bathroom Expectations

Quiz
•
6th - 8th Grade
20 questions
PBIS-HGMS

Quiz
•
6th - 8th Grade
10 questions
"LAST STOP ON MARKET STREET" Vocabulary Quiz

Quiz
•
3rd Grade
19 questions
Fractions to Decimals and Decimals to Fractions

Quiz
•
6th Grade
16 questions
Logic and Venn Diagrams

Quiz
•
12th Grade
15 questions
Compare and Order Decimals

Quiz
•
4th - 5th Grade
20 questions
Simplifying Fractions

Quiz
•
6th Grade
20 questions
Multiplication facts 1-12

Quiz
•
2nd - 3rd Grade