How to catch error?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lancet2003
Forum Newbie
Posts: 20
Joined: Sat Aug 09, 2003 11:29 pm

How to catch error?

Post 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
User avatar
mchaggis
Forum Contributor
Posts: 150
Joined: Mon Mar 24, 2003 10:31 am
Location: UK

Post by mchaggis »

Another way to stop a function displaying errors is to prefix an @ to the function eg

Code: Select all

@pg_connect()
lancet2003
Forum Newbie
Posts: 20
Joined: Sat Aug 09, 2003 11:29 pm

Post 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......"
markbeadle
Forum Commoner
Posts: 29
Joined: Tue Dec 02, 2003 2:50 am
Location: Aachen, Germany

Post by markbeadle »

Don't know how feasable/secure this would be...

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

Regards
Post Reply