couling Posted March 6, 2008 Share Posted March 6, 2008 Hi. How can I stop PHP from issueing warning messages when a PostgeSQL query fails. There are times when a query should fail... (users entering duplicate data into a unique index). But I want to handle these errors gracefully, wothout having php spit out a warning message to the user. I've tried changing php.ini without success: pgsql.ignore_notice = 1 pgsql.log_notice = 1 If it can not be solved then I could tell PHP not to give any warnings / errors to the user, but I was hoping for a solution that left other (non-PostgreSQL) messages in. Thanks for your time. Link to comment https://forums.phpfreaks.com/topic/94741-suppress-warning-messages-from-postgresql/ Share on other sites More sharing options...
mainewoods Posted March 6, 2008 Share Posted March 6, 2008 use '@' in front of the function when you call it. All PHP expressions can also be called with the "@" prefix, which turns off error reporting for that particular expression. If an error occurred during such an expression and the track_errors feature is enabled, you can find the error message in the global variable $php_errormsg. Note: The @ error-control operator prefix will not disable messages that are the result of parse errors. Warning Currently the @ error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. Among other things, this means that if you use @ to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why. Link to comment https://forums.phpfreaks.com/topic/94741-suppress-warning-messages-from-postgresql/#findComment-485075 Share on other sites More sharing options...
craygo Posted March 6, 2008 Share Posted March 6, 2008 you can always just put a @ in front of the function example @mysql_query($sql); that will suppress any error for ANY function regardless of mysql, or postgesql It is a php thing Ray Link to comment https://forums.phpfreaks.com/topic/94741-suppress-warning-messages-from-postgresql/#findComment-485077 Share on other sites More sharing options...
cooldude832 Posted March 6, 2008 Share Posted March 6, 2008 errors shouldn't happen in properly written scripts. Link to comment https://forums.phpfreaks.com/topic/94741-suppress-warning-messages-from-postgresql/#findComment-485083 Share on other sites More sharing options...
craygo Posted March 6, 2008 Share Posted March 6, 2008 errors shouldn't happen in properly written scripts. AMEN!! Link to comment https://forums.phpfreaks.com/topic/94741-suppress-warning-messages-from-postgresql/#findComment-485088 Share on other sites More sharing options...
couling Posted March 10, 2008 Author Share Posted March 10, 2008 Thanks for telling me about "@". I diddn't know about that before now. errors shouldn't happen in properly written scripts. There are times when a query should fail... (users entering duplicate data into a unique index). But I want to handle these errors gracefully, wothout having php spit out a warning message to the user. ... Properly written scripts are no match for user error. Link to comment https://forums.phpfreaks.com/topic/94741-suppress-warning-messages-from-postgresql/#findComment-488379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.