开发者

If an error occurs, how do i insert the incident in to the db using the following script?

If a duplicate id error occurs i want to record it into the db. I am usin开发者_如何学Gog this snippet below, how do i make room for it to insert the error information in the db?

Code:

 if ( $postedid === $storedid ) {
 require("error.php");
 die("");
 }else{ 
 echo("");
 }


You have to insert it before you close the script ( die() ). You insert a db query to log the error.


You simply pass the MySQL Query into the die(); function.

You would get the errors using

mysqli.errno.php and mysqli.error.php

DB QUERY -

INSERT INTO error (type, page) VALUES ('{mysqli_error($dbc)}','{$_SERVER['PHP_SELF']}')

<?php
if ( $postedid === $storedid ) {
 require("error.php");
    $type = mysqli_error($dbc); //Where $dbc is your connection resource. 
    $file = $_SERVER['PHP_SELF'];
      $q = "INSERT INTO error (type, page) VALUES ('{$type}','{$file}')";

 die( $r = mysqli_query ($dbc, $q) );}
 else{ 
    echo("");
 }

?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜