PHP MySQL Error Log Function -
what thoughts of using following function log mysql errors?
<?php function sql_query($query) { $q = mysql_query($query); if(!$q) { mysql_query('insert mysql_errors (error_query, error_about) values ('. $query.', '.mysql_error().' )'); } return $q; } ?>
do find useful? how can improved?
should be:
mysql_query("insert mysql_errors (error_query, error_about, error_date) values ('". mysql_real_escape_string($query)."', '".mysql_real_escape_string(mysql_error())."',now())");
i added date field , sanitised input. there needs way differentiate new , old errors , date field that.
Comments
Post a Comment