database-error-reporter
Gesponsorde koppelingen
PHP script bestanden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?
session_start();
//---- create function
function dberror($sql, $line)
{
//---- some needed mail vars
$email_to = "[email protected]";
$email_subject = "MySQL db error @ " . date('d.m.Y H:i');
$email_from = "From: Automatisch <[email protected]>";
$email_headers = "From: DB error reporter <[email protected]>\r\n";
$email_headers .= "MIME-Version: 1.0\r\n";
$email_headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
//---- generate db error report
$error = "<pre style=\"position: absolute; top: 20px; left: 20px; background-color: #FCFCFC; border: 1px solid #CCCCCC; padding: 8px; width: 100%; z-index: 5;\"><code>";
$error .= "<div style=\"float: left; width: 90px;\" valign=\"top\">";
$error .= "<b>Query:</b><br />";
$error .= "<b>Error:</b><br />";
$error .= "<b>Line:</b><br />";
$error .= "<b>Page:</b><br />";
$error .= "<b>Date/time:</b><br />";
$error .= "<b>IP addr:</b><br />";
$error .= "</div><div valign=\"top\">";
$error .= $sql . "<br />";
$error .= mysql_error() . "<br />";
$error .= $line . "<br />";
$error .= $_SERVER['PHP_SELF'] . "<br />";
$error .= date('d.m.Y H:i') . "<br />";
$error .= $_SERVER['REMOTE_ADDR'] . "<br />";
$error .= "</div></code></pre>";
//---- check for first try
if (!$_SESSION['dberror_mail'])
{
mail($email_to, $email_subject, $error, $email_headers);
$_SESSION['dberror_mail'] = 1;
}
//---- return the database error
return $error;
}
//---- execute any kind of query to test the error report
//---- in this case I've forgot to make a database connection (Oops!)
$sql = "SELECT * FROM iets_niet_bestaans";
$res = @mysql_query($sql) or die(dberror($sql, __LINE__));
?>
session_start();
//---- create function
function dberror($sql, $line)
{
//---- some needed mail vars
$email_to = "[email protected]";
$email_subject = "MySQL db error @ " . date('d.m.Y H:i');
$email_from = "From: Automatisch <[email protected]>";
$email_headers = "From: DB error reporter <[email protected]>\r\n";
$email_headers .= "MIME-Version: 1.0\r\n";
$email_headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
//---- generate db error report
$error = "<pre style=\"position: absolute; top: 20px; left: 20px; background-color: #FCFCFC; border: 1px solid #CCCCCC; padding: 8px; width: 100%; z-index: 5;\"><code>";
$error .= "<div style=\"float: left; width: 90px;\" valign=\"top\">";
$error .= "<b>Query:</b><br />";
$error .= "<b>Error:</b><br />";
$error .= "<b>Line:</b><br />";
$error .= "<b>Page:</b><br />";
$error .= "<b>Date/time:</b><br />";
$error .= "<b>IP addr:</b><br />";
$error .= "</div><div valign=\"top\">";
$error .= $sql . "<br />";
$error .= mysql_error() . "<br />";
$error .= $line . "<br />";
$error .= $_SERVER['PHP_SELF'] . "<br />";
$error .= date('d.m.Y H:i') . "<br />";
$error .= $_SERVER['REMOTE_ADDR'] . "<br />";
$error .= "</div></code></pre>";
//---- check for first try
if (!$_SESSION['dberror_mail'])
{
mail($email_to, $email_subject, $error, $email_headers);
$_SESSION['dberror_mail'] = 1;
}
//---- return the database error
return $error;
}
//---- execute any kind of query to test the error report
//---- in this case I've forgot to make a database connection (Oops!)
$sql = "SELECT * FROM iets_niet_bestaans";
$res = @mysql_query($sql) or die(dberror($sql, __LINE__));
?>