Jump to content

Suppress warning messages from postgresql


couling

Recommended Posts

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.

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.

 

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.