Page 1 of 1

How to catch error?

Posted: Tue Dec 02, 2003 11:47 pm
by lancet2003
Hi:
I use pg_connect() to connect to my postgresql database, when there is a mistake, the php engine will echo the error message, can someone tell me how to catch this error message to give its value to a variable. I guess error_handler can do, any other methods?

eg. I want to catch this error message and make it the value of a variable named $messagebody, and then send it to my mailbox.

sincerely

Yuping Wang

Posted: Wed Dec 03, 2003 3:09 am
by mchaggis
Another way to stop a function displaying errors is to prefix an @ to the function eg

Code: Select all

@pg_connect()

Posted: Wed Dec 03, 2003 10:15 am
by lancet2003
Thanks for replay, but what I need is to get this message and transfer its value to a string variable.

LIke: The system message shows: Unknown mistake bla......

THen I can realize:
$mesbody="Unknown mistake bla......"

Posted: Wed Dec 03, 2003 10:30 am
by markbeadle
Don't know how feasable/secure this would be...

Could you possibly set it to the tail of the log file ?

Regards