Lassie Posted July 5, 2007 Share Posted July 5, 2007 I am using a purpose built error handler for development and get an error message as follows:- Warning: Wrong parameter count for print_r() in c:\easyserv\www\timeshare1\includes\config.inc.php on line 23 Can anyone help please. <?php # - config.inc.php // This script determines how errors are handled. // Flag variable for site status: $live = TRUE; // Error log email address: $email = '[email protected]'; // Create the error handler. function my_error_handler ($e_number, $e_message, $e_file, $e_line, $e_vars) { global $live, $email; // Build the error message. $message = "An error occurred in script '$e_file' on line $e_line: \n<br />$e_message\n<br />"; // Add the date and time. $message .= "Date/Time: " . date('n-j-Y H:i:s') . "\n<br />"; // Append $e_vars to the $message.//Line 23 $message .= print_r($e_vars,1); if ($live) { // Don't show the specific error. error_log ($message, 1, $email); // Send email. // Only print an error message if the error isn't a notice. if ($e_number != E_NOTICE) { echo '<div id="Error">A system error occurred. We apologize for the inconvenience.</div><br />'; } } else { // Development (print the error). echo '<div id="Error">' . $message . '</div><br />'; } } // End of my_error_handler() definition. // Use my error handler. set_error_handler ('my_error_handler'); ?> Link to comment https://forums.phpfreaks.com/topic/58565-customised-error-handler-gives-error-message/ Share on other sites More sharing options...
soycharliente Posted July 5, 2007 Share Posted July 5, 2007 Isn't the second parameter a bool? Try using true/false. Link to comment https://forums.phpfreaks.com/topic/58565-customised-error-handler-gives-error-message/#findComment-290502 Share on other sites More sharing options...
Lassie Posted July 5, 2007 Author Share Posted July 5, 2007 Thanks for coming back. The second arguement is supposed to make the function return the result instead of printing it. True and false both give the same error. Link to comment https://forums.phpfreaks.com/topic/58565-customised-error-handler-gives-error-message/#findComment-290519 Share on other sites More sharing options...
akitchin Posted July 5, 2007 Share Posted July 5, 2007 the extra parameter in print_r() only existed past a certain PHP version. check yours, and make sure it's compatible. Link to comment https://forums.phpfreaks.com/topic/58565-customised-error-handler-gives-error-message/#findComment-290523 Share on other sites More sharing options...
Lassie Posted July 5, 2007 Author Share Posted July 5, 2007 Thanks. Will do.I am running 4.2.2 Link to comment https://forums.phpfreaks.com/topic/58565-customised-error-handler-gives-error-message/#findComment-290542 Share on other sites More sharing options...
akitchin Posted July 5, 2007 Share Posted July 5, 2007 from the manual: Version Description 4.3.0 The return parameter was added. If you need to capture the output of print_r() with an older version of PHP prior, use the output-control functions. see http://ca3.php.net/manual/en/function.print-r.php Link to comment https://forums.phpfreaks.com/topic/58565-customised-error-handler-gives-error-message/#findComment-290543 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.