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.

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.