Re: Error Trapping

From: Date: Fri, 10 Jul 2009 15:44:34 +0000
Subject: Re: Error Trapping
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-295147@lists.php.net to get a copy of this message
On Fri, Jul 10, 2009 at 11:39 AM, Floyd Resler<fresler@adex-intl.com> wrote: > Eddie, >        Thanks for the tip.  It suddenly occurred to me what I was doing > wrong.  I do use an error trap but I was telling my script to stop running > after the error.  So, now I ignore it and continue through the loop you > suggested.  I guess it was working exactly the way I had written it! > > Thanks! > Floyd > > On Jul 10, 2009, at 11:23 AM, Eddie Drapkin wrote: > >> On Fri, Jul 10, 2009 at 10:56 AM, Floyd Resler<fresler@adex-intl.com> >> wrote: >>> >>> I'm having a hard time getting my head around this problem.  I have to >>> connect to a FoxPro database using an ODBC driver.  Sometimes when I >>> connect >>> I get an error.  The error doesn't occur all the time and usually another >>> connect attempt works.  I can trap the error through an error handler. >>>  However, I use a class to connect to the database.  What I want to do is >>> to >>> check for that error and, if it occurs, try to connect again.  Since the >>> error handler is outside the class, how can I create the object again and >>> make sure it gets passed back to my script that called it?  I hope that >>> made >>> sense! >>> >>> Thanks! >>> Floyd >> >> Why is the error outside the class? If you connect with a class, something >> like: >> >> public function __construct() { >>  $this->handle = false; >>  while($this->handle === false) { >>   $this->handle == odbc_connect(); >>  } >> } >> >> ought to work fine.  Alternatively, you could check out PDO, which is >> supposed to be the next generation of database connections in PHP, and >> won't create an object without a connection. >> > > ;) Sometimes all it takes is a fresh look at an old problem!

« previous php.general (#295147) next »