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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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!! Quote Link to comment 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. Quote Link to comment 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.