Drop Shadow

PHP 5.3.0 Upgrade

The upgrade to PHP 5.3.0 (and possibly mysqlnd) brought some odd and annoying changes to how PHP works, especially concerning MySQL.


  1. mysql_close() requires a resource link identifier; without one, the script will crash on that line.
  2. mysql_insert_id() needs to be immediately following the mysql_query() that does the insert. If any other queries, even non-inserting queries, separate the insert query from mysql_insert_id() you’ll get a zero back as the ID.


  1. PHP 5.3.0 is less forgiving of blank lines at the beginning of a page. Any blank lines will now cause PHP to send headers, thus invalidating any header() functions in the page.
  2. getHostName() is now a built-in function; having a function of that name will fail.
  3. SCRIPT_URL is gone; SCRIPT_NAME seems to be its replacement. However, note that SCRIPT_NAME will sometimes contain index.php or other index filenames.
  4. Something changed with the way PHP stores errors in $_FILES. When the upload field name is an array (i.e., it uses square brackets), $_FILES consists of a top-level array as normal with the variable names, and then each of the pieces of info is itself an array with the index names. For example, if the form has an upload for photoOp[us] and photoOp[them], the $_FILES array will be something like:
    • photoOp
      • name
        • [us]: filename1.jpg
        • [them]: filename2.jpg
      • error
        • [us]: UPLOAD_ERR_OK
        • [them]: UPLOAD_ERR_INI_SIZE
    This means that if you are checking for an error and you are uploading using bracket notation, you have to check inside the error array; otherwise, you’ll always detect an error because the error array will not be empty.