PHP2e_Chapter08_ReviewQuestions

True/False
Indicate whether the statement is true or false.

____	1.	The PHP Extension and Application Representation (PEAR) is a committee that oversees the open source PHP code.

____	2.	One of the most popular PEAR code modules is PEAR DB, which simplifies access between PHP and a database server.

____	3.	How you enable MySQL support in PHP depends on the version of PHP and how you installed MySQL.

____	4.	The mysqli package is the object-oriented equivalent of the mysql package.

____	5.	The mysql_connect() function returns a 1 if it connects to the database successfully or 0 if it doesn’t.

____	6.	The mysql_close() function is used to explicitly close a database connection.

____	7.	The mysql_error() function returns a value of FALSE if it detects an error.

____	8.	You can suppress error message by using the error control operator (%).

____	9.	The error control operator disables error checking.

____	10.	You can use the mysql_select_db() function to select a database or change to a different database.

____	11.	The mysql_delete_db("dbname"[, connection]); script is used to delete a database.

____	12.	PHP, you use the mysql_send() function to send SQL statements to MySQL.

____	13.	A list of records that are returned from a query is called a resultset.

____	14.	The query pointer is a way of keeping track of where you are in a resultset.

____	15.	To prevent code from trying to create a table that already exists, use the SHOW EXISTING TABLES command.

____	16.	The PRIMARY KEY keywords are used to generate a unique id for each new row in a table.

____	17.	The NOT NULL keywords are often used with primary keys to require that a field include a value.

____	18.	When you add records to a table that includes an AUTO_INCREMENT field,  you omit the column name and value from the lists.

____	19.	The first record added to a table that has an auto-incrementing primary key will be assigned a value of 0.

____	20.	To update records in a table, use the UPDATE, SET, and WHERE keywords with the mysql_query() function.

____	21.	To delete records in a table, use the DELETE and WHERE keywords with the mysql_query() function.

____	22.	With queries that return results, such as SELECT queries, you can use the mysql_num_rows() function to find the number of records returned from a query.

____	23.	With queries that modify tables, but do not return results, such as INSERT, UPDATE, and DELETE queries, you use the mysql_modified_rows() function to determine the number of changed rows.

____	24.	You pass the mysql_affected_rows() function the variable containing the result pointer from the mysql_query() function.

____	25.	The mysql_info() function returns the number of operations for various types of actions, depending on the type of query.

____	26.	The mysql_info() function also returns information for LOAD DATA queries.

____	27.	The mysql_query() function returns a result pointer that represents the query results when the SELECT or SHOW statement which returns a resultset.

____	28.	The mysql_fetch_row() function returns the fields in the current row of a resultset into an indexed array and moves the result pointer to the next row.

____	29.	The mysql_fetch_assoc() function returns the fields into an associative array and uses each row name as the array key.

____	30.	When you are finished working with query results retrieved with the mysql_query() function, you should use the mysql_free_resultset() function to close the resultset.

____	31.	You use the mysql_num_fields() function to return the number of  _______________ in a query result.

Multiple Choice
Identify the choice that best completes the statement or answers the question.

____	32.	The ____ package is designed to work with MySQL version 4.1.3 and higher.
a.	mysql	c.	libmysql	
b.	mysqli	d.	ext_mysqli	

____	33.	To open a connection to a MySQL database server, use ____.
a.	mysql_connect()	c.	connection_mysql()	
b.	open_connect()	d.	open_mysql()	

____	34.	To close a database connection, use ____.
a.	close_connection()	c.	mysql_exit()	
b.	mysql_close()	d.	close_mysql()	

____	35.	To return information about the MySQL database server version, use the ____ function.
a.	mysql_get_client_info()	
b.	mysql_host_info(connection)	
c.	mysql_get_proto_info(connection)	
d.	mysql_get_server_info(connection)	

____	36.	The ___ function returns a text string describing the error in PHP code.
a.	mysql_error()	c.	mysql_err()	
b.	mysql_errno()	d.	mysql_error_number()	

____	37.	The symbol (@), used to suppress error messages, is called ____.
a.	supression operator	c.	null operator	
b.	error control operator	d.	no_error operator	

____	38.	You select a database or change to a different database with the ____ function.
a.	mysql_select_database()	c.	mysql_select_db()	
b.	mysql_change_database()	d.	mysql_change_db()	

____	39.	To delete a database, use the ____ function.
a.	mysql_delete_db()	c.	mysql_delete_database()	
b.	mysql_drop_db()	d.	mysql_drop_database()	

____	40.	Almost every command sent to MySQL from PHP  is executed with the ____ function.
a.	mysql_connect()	c.	mysql_send()	
b.	mysql_select()	d.	mysql_query()	

____	41.	A result pointer is a special type of ____ that refers to the currently selected row in a resultset.
a.	variable	c.	function	
b.	option	d.	command	

____	42.	The list of records that is returned from a mysql_query() is a called a ____.
a.	recordset	c.	result	
b.	resultset	d.	result query	

____	43.	When mysql_query() returns a resultset, you use the  ____ function to determine the number of records in the resultset.
a.	mysql_result_rows()	c.	mysql_num_rows()	
b.	mysql_num_result()	d.	mysql_num_records()	

____	44.	The ____ command with a mysql_query() function executes successfully if the table already exists.
a.	SHOW EXISTING TABLE	c.	SHOW SAME TABLE	
b.	SHOW MATCHING TABLE	d.	SHOW TABLES LIKE	

____	45.	The ___ keyword is often used with the primary key to generate a unique id for each new row in a table.
a.	UNIQUE_ID	c.	AUTO_INCREMENT	
b.	INCREMENT_ID	d.	AUTO_INCREMENT_ID	

____	46.	The ___ keyword, often used with the primary key, requires that the field include a value.
a.	NOT NULL	c.	NOT EMPTY	
b.	NOT BLANK	d.	NOT VOID	

____	47.	To add multiple records to a database from an external file, you use the ____ statement with the name of the local text file that contains the records you want to add.
a.	INSERT DATA	c.	INSERT RECORDS	
b.	LOAD DATA	d.	UPLOAD RECORDS	

____	48.	To change records in a table, use the UPDATE keyword to specify the name of the table to update and the ___ keyword to specify the value to assign to the fields in the records that match the condition in the WHERE keyword. 
a.	CHANGE	c.	PUT	
b.	INSERT	d.	SET	

____	49.	To delete records in a table, use the keywords ____.
a.	DELETE, RECORD	c.	REMOVE, WHERE	
b.	DELETE, WHERE	d.	REMOVE, RECORD	

____	50.	When a query modifies a table but does not return a result, you use the ___ function to determine how many rows/records were affected.
a.	mysql_rows_affected()	c.	mysql_affected_records()	
b.	mysql_affected_rows()	d.	mysql_records_affected()	

____	51.	With an INSERT query, the ___ function returns the number of records added and duplicated along with the number of warnings.
a.	mysql_update_info()	c.	mysql_update()	
b.	mysql_info()	d.	mysql_info_update()	

____	52.	The mysql_info() function only returns query information when you add ___ records with the INSERT keyword.
a.	one	c.	less than five	
b.	more than one	d.	no records	

____	53.	The function ____ returns the fields in the current row into an indexed array.
a.	mysql_fetch_assoc()	c.	mysql_fetch_row()	
b.	mysql_data_seek()	d.	mysql_fetch_lengths()	

____	54.	The function ____ returns the fields in the current row of a resultset into an associative array and moves the result pointer to the next row.
a.	mysql_fetch_lengths()	c.	mysql_fetch_rows()	
b.	mysql_fetch_assoc()	d.	mysql_fetch_array()	

____	55.	To close the resultset, use ____.
a.	mysql_close()	c.	mysql_exist()	
b.	mysql_kill()	d.	mysql_free_result()	

____	56.	Use the ___ function to return the number of fields in a query result.
a.	mysql_return_fields()	c.	mysql_count_fields()	
b.	mysql_num_fields()	d.	mysql_field_results()	

PHP2e_Chapter08_ReviewQuestions
Answer Section

TRUE/FALSE

	1.	REF:	447

	2.	REF:	447

	3.	REF:	448

	4.	REF:	448

	5.	REF:	448

	6.	REF:	449

	7.	REF:	451

	8.	REF:	452

	9.	REF:	452

	10.	REF:	455

	11.	REF:	458

	12.	REF:	459

	13.	REF:	459

	14.	REF:	459

	15.	REF:	461

	16.	REF:	461

	17.	REF:	462

	18.	REF:	465

	19.	REF:	465

	20.	REF:	465

	21.	REF:	465 | 466

	22.	REF:	470

	23.	REF:	470

	24.	REF:	470

	25.	REF:	471

	26.	REF:	471

	27.	REF:	473

	28.	REF:	474

	29.	REF:	477

	30.	REF:	479

	31.	ANS:	T
fields

PTS:	1	REF:	480

MULTIPLE CHOICE

	32.	REF:	448

	33.	REF:	448

	34.	REF:	449

	35.	REF:	449

	36.	REF:	451

	37.	REF:	452

	38.	REF:	455

	39.	REF:	458

	40.	REF:	459

	41.	REF:	459

	42.	REF:	459

	43.	REF:	460

	44.	REF:	461

	45.	REF:	461

	46.	REF:	462

	47.	REF:	465

	48.	REF:	465

	49.	REF:	465

	50.	REF:	470

	51.	REF:	471

	52.	REF:	471

	53.	REF:	474

	54.	REF:	474

	55.	REF:	479

	56.	REF:	480