djfox Posted December 28, 2008 Share Posted December 28, 2008 I have this currently: mysql_query("UPDATE userdata SET regions_loc='$loc', regions_url='$url', regid='$regid' WHERE id='$logged'")or die ( mysql_error()); Are there ways to customize the error message that would print out? Link to comment https://forums.phpfreaks.com/topic/138657-solved-customize-error-message/ Share on other sites More sharing options...
waterssaz Posted December 28, 2008 Share Posted December 28, 2008 you can achieve this using something like mysql_query($query) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error()); :-) Link to comment https://forums.phpfreaks.com/topic/138657-solved-customize-error-message/#findComment-724944 Share on other sites More sharing options...
djfox Posted December 28, 2008 Author Share Posted December 28, 2008 Great, thank you very much Link to comment https://forums.phpfreaks.com/topic/138657-solved-customize-error-message/#findComment-724949 Share on other sites More sharing options...
premiso Posted December 28, 2008 Share Posted December 28, 2008 It depends on how you want to "customize it" In a production enviroment it is not good to display real errors to users. In a case like that I would create my own function called "errorReport" or something similiar. This would email the admin the error and then display a friendly message like this: function errorReport($msg, $mysql=false) { if ($mysql) { $msg .= " MySQL Error: " . mysql_error(); } mail(ADMIN_EMAIL, "Error", $msg, HEADERS); // note ADMIN_EMAIL and HEADERS are constants that need to be defined. die("An error has occurred, the admin has been emailed. We apologize for this issue."); } That way you know about the error and the user is displayed a nice message letting them know about the error. That is how I handle it (well in a similiar fashion just more robust). Link to comment https://forums.phpfreaks.com/topic/138657-solved-customize-error-message/#findComment-724951 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.