Find MySQL Query errors and stored in Text file
This is important method to find MySQL query error, hacker trying different way to access our website. we can easily find what they are trying. we can prevent the SQL injection.
The most website working in php and mysql, we can find the Query error using below code
MySQL Query
$query1= "select * from tbl_leaser where lid>0"; if(!mysql_query($query1)){ $path = $_SERVER['PHP_SELF']; queryerror($path); }
Common Function for Store in Text File
function queryerror($path) { $filename = "error.txt"; $contents = mysql_error(). 'This error occurred on '.date("D M j G:i:s T Y",time()).$path; $handle = fopen($filename, 'a'); fwrite($handle, $contents); fclose($handle); }
Another Way using ini_set
//the below statement is used to store the errors in error_log.txt error_reporting(E_ALL); ini_set('log_errors',TRUE); ini_set('html_errors',FALSE); ini_set('error_log','error_log.txt');//D:xampphtdocsmyfolderpojectnameerror_log.txt ini_set('display_errors',FALSE);