[PHP] Error Trapping

2009-07-10 Thread Floyd Resler
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
 
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Error Trapping

2009-07-10 Thread Eddie Drapkin
On Fri, Jul 10, 2009 at 10:56 AM, Floyd Reslerfres...@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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Error Trapping

2009-07-10 Thread Floyd Resler

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 Reslerfres...@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.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Error Trapping

2009-07-10 Thread Eddie Drapkin
On Fri, Jul 10, 2009 at 11:39 AM, Floyd Reslerfres...@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 Reslerfres...@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!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Error trapping

2001-09-03 Thread Tim Ward

I've gone an annoying problem. On our site I've trapped file does not
exist errors at Apache level to send out my own error screen with a company
logo, link to home page and a mailto link, but this doesn't work for any
request for a page that would be parsed by php if it existed. In this case a
valid html page (containing the php error) is returned. The problem seems to
be that as far as Apache is concerned there isn't an error. I haven't found
anything in php that allows me to trap errors like this. Error reporting
levels aren't helpful as I still need the error trapped.

I'm sure I'm not the first person who has come across this, and I'm hoping
someone out there has found a way around it.

I'm running PHP 4.0.0, Apache 1.3 on NT (yes I know, but our network manager
has promised me a linux box)

Tim Ward
Senior Systems Engineer

Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] error trapping

2001-07-27 Thread Phil Spitler

I am wondering the best way to handle error trapping with PHP.  I am
farmiliar with languages, ColdFusion being one, that you can use TRY and
CATCH statements.  Any info would be appreciated.

THANKS!

-
Phil Spitler [Vice President]
Web Hut Design, Inc.
c 704-451-1324
mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] error trapping

2001-07-26 Thread Phil Spitler

I am wondering the best way to handle error trapping with PHP.  I am
farmiliar with languages, ColdFusion being one, that you can use TRY and
CATCH statements.  Any info would be appreciated.

THANKS!

-
Phil Spitler [Vice President]
Web Hut Design, Inc.
c 704-451-1324
mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]