Don't pass null to the mysql error functions. Even though the PHP documentation states a null value can be passed, a warning message is given it is passed.