Chapter 10 Answers

  1. The standard MySQL function used for connecting to a MySQL database is mysql_connect.

  2. 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.

  3. The POST form method is generally better than GET because the fields are posted directly, rather than appending them 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.)

  4. To determine the last-entered value of an AUTO_INCREMENT column, use the mysql_insert_id function.

  5. The PHP function that escapes a string, making it suitable for use with MySQL, is mysql_real_escape_string.

  6. Cross-site scripting injection attacks can be prevented using the htmlentities function.

Get Learning PHP, MySQL, JavaScript, and CSS, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.