Wrox Programmer Forums
|
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 3rd, 2003, 01:50 AM
Registered User
 
Join Date: Aug 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to catch error.

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.

Your help would be appreciated!

Yuping Wang


Thanks!
 
Old December 3rd, 2003, 02:16 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can suppress an error message by prefixing the function with the at symbol (@).
  http://www.php.net/operators.errorcontrol

$link = @pg_connect();

If pg_connect fails, it returns false.
  http://www.php.net/pg_connect

You can test the value of $link and send yourself an email if $link is FALSE.


Also, you should read the manual section on error handling functions:
  http://www.php.net/errorfunc


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
catch 404 error danielnixon ASP.NET 2.0 Basics 1 May 1st, 2008 06:57 PM
Unable to catch error HttpException (0x80004005): Shibu General .NET 6 May 22nd, 2007 04:21 AM
Catch PHP error Mantis Pro PHP 7 January 19th, 2005 01:05 PM
Catch POST error ? Mantis HTML Code Clinic 1 December 18th, 2004 06:37 PM
Catch and display an appropriate error nambati General .NET 3 December 16th, 2004 11:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.