Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   BT.Manager (phpMyBitTorrent) (http://www.bvlist.com/forumdisplay.php?f=23)
-   -   Error function explained (http://www.bvlist.com/showthread.php?t=3594)

joeroberts 14th October 2009 16:47

Error function explained
 
To generate a basic error report you can use 1 of 3 PMBT error functions
first is the btsqlerror which is the Mysql error
PHP Code:

btsqlerror($sql ''

where $sql is the query
example
PHP Code:

        $sql "SELECT id FROM ".$db_prefix."_users WHERE id = '".$user->id."' AND username = '".$user->name."' AND act_key = '".addslashes($userdata[3])."' AND password = '".addslashes($userdata[2])."';"

this well return a fatal error causing the script to come to a complete stop
and display a error block reporting the query the error code and Mysql message for this error
to use this
PHP Code:

                        $sql "SELECT avatar FROM ".$db_prefix."_users WHERE id = '".$uid."';";
                        
$res $db->sql_query($sql)or btsqlerror($sql); 

the Second is the display error bterror
PHP Code:

bterror($error$title _btgenerror$fatal true

$error is the body of the error block and is a required field
$tittle is the header of the error block this field is not required
$fatal tells the script if it should come to a complete stop or just carry on after display By default it is fatal and well stop the script.
example Fatal Error
PHP Code:

bterror("Error","you have a fatal error"); 

Example Non Fatal error
PHP Code:

bterror("Error","you have a nonfatal error",false); 

the last is error log
PHP Code:

logerror($message$error _btgenerror

this well write a log error in the data base of the error for site admin to view
in the admin logs
$message is the main error and is required
$error is the title of the error and is not required
this well add to the data base a row for error type error body user IP the created the error and a time stamp
Example
PHP Code:

logerror('User login failed for '.$username'Failed Login'); 



All times are GMT +2. The time now is 18:07.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.