phpSensei Posted August 9, 2011 Share Posted August 9, 2011 Hi there, I fail to see why mysqli_report doesn't turn off internal errors. The only thing turning off the errors is error_reporting, or maybe I am not seeing something here. At the moment, this is what's working. <?php mysqli_report(MYSQLI_REPORT_OFF); // Has no effect on the error output error_reporting(E_STRICT); class Valley_Mysqli extends mysqli{ public function __construct($V_Host,$V_User,$V_Pass,$V_Name){ parent::__construct($V_Host,$V_User,$V_Pass,$V_Name); try{ if(mysqli_connect_errno()){ throw new Valley_Error('Mysqli Cannot Connect',mysqli_connect_errno()); } }catch(Valley_Error $e){ print $e->getMessage(); } } } class Valley_Error extends Exception { public function __construct($mysqli_error_msg, $mysqli_error_code = 0, Exception $previous = null) { // assigned values properly parent::__construct('Mysqli Error Msg: '.$mysqli_error_msg, $mysqli_error_code , $previous); } } ## Testing $db = new Valley_Mysqli('localhost','root','','valley'); ?> MYSQLI_REPORT_OFF Turns reporting off MYSQLI_REPORT_ERROR Report errors from mysqli function calls MYSQLI_REPORT_STRICT Throw mysqli_sql_exception for errors instead of warnings MYSQLI_REPORT_INDEX Report if no index or bad index was used in a query MYSQLI_REPORT_ALL Set all options (report all) Quote Link to comment https://forums.phpfreaks.com/topic/244289-handling-mysqli-errors/ Share on other sites More sharing options...
phpSensei Posted August 9, 2011 Author Share Posted August 9, 2011 I guess the connection's error isn't controlled by mysqli itself? However, From the manual: mysqli_report() is a powerful function to improve your queries and code during development and testing phase. Depending on the flags it reports errors from mysqli function calls or queries which don't use an index (or use a bad index). Quote Link to comment https://forums.phpfreaks.com/topic/244289-handling-mysqli-errors/#findComment-1254694 Share on other sites More sharing options...
phpSensei Posted August 9, 2011 Author Share Posted August 9, 2011 Anybody? Quote Link to comment https://forums.phpfreaks.com/topic/244289-handling-mysqli-errors/#findComment-1254741 Share on other sites More sharing options...
phpSensei Posted August 9, 2011 Author Share Posted August 9, 2011 Still don't understand this, and I found a bug with this class. I guess i'll report the bug (if it is one), find a work around for the error_reporting. Quote Link to comment https://forums.phpfreaks.com/topic/244289-handling-mysqli-errors/#findComment-1254777 Share on other sites More sharing options...
TeNDoLLA Posted August 9, 2011 Share Posted August 9, 2011 From the comments in the manual, maybe this is some help? Be very careful using this function - it's a per-process setting. If your server is set up to reuse a single PHP process for multiple requests, that means the last setting of this function in any script will affect all other scripts using mysqli. To be safe always call <? mysqli_report(MYSQLI_REPORT_OFF) ?> at the end of a script. The CGI version of PHP is probably safe from this. Quote Link to comment https://forums.phpfreaks.com/topic/244289-handling-mysqli-errors/#findComment-1254825 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.