Section 1

Preview this deck

Which of the following characters suppresses error messages in PHP?

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 14, 2020

Cards (20)

Section 1

(20 cards)

Which of the following characters suppresses error messages in PHP?

Front

@

Back

Write a simple code segment that demonstrates how to use a mysqli_query() function to prevent your code from attempting to create a table that already exists

Front

$TableName = "CoolTable"; $SQLstring = "SHOW TABLES LIKE '$TableName'"; $QueryResult = mysqli_query($DBConnect, $SQLstring); if ($mysqli_num_rows($QueryResult) == 0) { $SQLstring = "CREATE TABLE $TableName (primarykeyname SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(20))"; mysqli_query($DBConnect, $SQLstring); } else echo "<p>Table already exists!</p>";

Back

Which of the following functions closes a database connection?

Front

mysqli_close()

Back

Write a simple code segment that demonstrates how to use the mysql_num_rows() and mysql_num_fields() functions to determine whether a SQL query returned results.

Front

$SQLstring = "SELECT whatever fields you want to access FROM table_name"; $QueryResult = mysqli_query($SQLstring, $DBConnect); if (mysqli_num_rows($QueryResult) == 0 || mysqli_num_fields($QueryResult) == 0) echo "<p>Query returned no results.</p>"; else echo "<p>Your query returned" . mysqli_num_rows($QueryResult) . " rows and " . mysqli_num_fields($QueryResult . " fields.</p>";

Back

Which of the following functions terminates script execution?

Front

die()

Back

The following code structure prevents MySQL error messages from being displayed if the database connection is not available. True or false?

Front

$DBConnect = mysqli_connect("localhost", "dongosselin", "rosebud"); if (!$DBConnect) echo "<p>The database server is not available.</p>"; else { echo "<p>Successfully connected to the database server.</p>"; mysqli_close($DBConnect); } False- it should be an @ symbol instead of exclamation point

Back

To which of the following functions do you need to pass a variable representing the database connection?

Front

b. mysqli_get_host_info() c. mysqli_get_proto_info() d. mysql_get_server_info()

Back

Which of the following functions returns the fields in the current row of a resultset into an associative array?

Front

mysqli_fetch_assoc()

Back

What is the correct syntax for selecting a database with the mysqli_select_db() function?

Front

Using mysqli_*, none of the given options are right. Correct syntax is: mysqli_select_db(connection, database)

Back

Which of the following statements is used to create a query string in the $SQLstring to delete the company_cars table?

Front

$SQLstring = "DROP TABLE company_cars";

Back

Describe three types of errors that can occur when accessing MySQL databases and other types of data sources with PHP.

Front

Errors can occur when connecting to a server initially, when trying to select a database, and when trying to select and manipulate a table.

Back

When using the INSERT and VALUE keywords to add records to a table using the mysql_query() function, what keyword is used to indicate that there is no value for a field?

Front

NULL

Back

Which of the following SQL keywords creates an auto-incrementing field?

Front

AUTO_INCREMENT

Back

Which of the following functions closes a resultset to ensure that it doesn't keep taking up space in your Web server's memory?

Front

mysqli_free_result()

Back

The _____ function returns the number of operations for various types of actions, depending on the type of query.

Front

mysqli_info()

Back

Which of the following functions reports the error message from the last failed database connection attempt?

Front

mysqli_error()

Back

Which of the following functions returns the number of rows affected by queries that do not return results, such as INSERT, UPDATE, and DELETE queries?

Front

mysqli_affected_rows()

Back

Which of the following functions returns the fields in the current row of a resultset into an indexed array?

Front

b. mysqli_fetch_array() d. mysql_fetch_row()

Back

Which of the following functions opens a database connection?

Front

mysqli_connect()

Back

Explain what a result pointer is and how to create and use one.

Front

A result pointer is a special variable that refers to the currently selected row in the table. It is used to keep track of where you are in the resultset. To create a result pointer, assign the result pointer to a variable that executes a mysql_query() function.

Back