Search Header Logo

Connecting to a Database using PHP (Part 2)

Authored by JX Chow

Computers

Professional Development

Used 2+ times

Connecting to a Database using PHP (Part 2)
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

9 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?