Chapter 10 - Accessing MySQL Flashcards
What is the standard PHP function for connecting to a MySQL database?
The standard MySQL function used for connecting to a MySQL database is mysql_connect.
When is the mysql_result function not optimal?
The mysql_result function is not optimal when more than one cell is being requested, because it fetches only a single cell from a database and therefore has to be called multiple times, whereas mysql_fetch_row will fetch an entire row.
Give one reason why using the POST form method is usually better than GET.
The POST form method is generally better than GET, because the fields are posted directly, rather than being appended to the URL. This has several advantages, particularly in removing the possibility to enter spoof data at the browser’s address bar. (It is not a complete defense against spoofing, however.)
How can you determine the most recently entered value of an AUTO_INCREMENT column?
To determine the last entered value of an AUTO_INCREMENT column, use the mysql_insert_id function
Which PHP function escapes a string, making it suitable for use with MySQL
The PHP function that escapes characters in a string, making it suitable for use with MySQL, is mysql_real_escape_string
Which function can be used to prevent XSS injection attacks?
The function htmlentities can be used to prevent cross-site scripting injection attacks.