PHP Classes

Bug with $db->Close()

Recommend this page to a friend!

      Ultimate MySQL  >  All threads  >  Bug with $db->Close()  >  (Un) Subscribe thread alerts  
Subject:Bug with $db->Close()
Summary:I get a fatal error at the bottom of my pages with $db->Close()
Messages:8
Author:Mark Smith
Date:2007-12-08 09:12:21
Update:2010-12-23 16:17:58
 

  1. Bug with $db->Close()   Reply   Report abuse  
Picture of Mark Smith Mark Smith - 2007-12-08 09:12:23
Hi Everyone,

I have just started using this script.

At the bottom of my pages I get the text 'Exception thrown without a stack frame in Unknown on line 0', not exactly the most descriptive error message I've see ;)

When I comment out $db->Close(); it disappears.

Any ideas?

Cheers

  2. Re: Bug with $db->Close()   Reply   Report abuse  
Picture of Jeff Williams Jeff Williams - 2008-01-10 22:32:20 - In reply to message 1 from Mark Smith
I haven't ever seen this error before. Is it still happening?

  3. Re: Bug with $db->Close()   Reply   Report abuse  
Picture of Owen Lees Owen Lees - 2008-01-12 13:46:22 - In reply to message 2 from Jeff Williams
I get this too, just to be awkward :)

Oo

  4. Re: Bug with $db->Close()   Reply   Report abuse  
Picture of Ricardo Henrique Ricardo Henrique - 2008-07-28 20:28:27 - In reply to message 2 from Jeff Williams
still, I believe that is in line 1154 to file mysql.class.php with the command mysql_free_result, to comment on the line and the error disappears. If comment on this line, what problems can I have?

and excuse me for my bad English.

  5. Re: Bug with $db->Close()   Reply   Report abuse  
Picture of Asif M Asif M - 2009-05-22 12:42:48 - In reply to message 2 from Jeff Williams
Hi,
While using script i am also getting same error for first time and then is doesn't come.

I found that our distruct method is causing error as found that:
"Attempting to throw an exception from a desctructor causes a fatal error"

Is there any solution to above problem?

  6. Re: Bug with $db->Close()   Reply   Report abuse  
Picture of robson robson - 2009-08-20 16:28:22 - In reply to message 5 from Asif M
Hi,

imho the error occurs only if you set $db->ThrowExceptions = true.
If you add $this->ThrowExceptions = false to the "Close"-method the error is gone.

robson

  7. Re: Bug with $db->Close()   Reply   Report abuse  
Picture of Vincent Vincent - 2009-12-16 21:47:23 - In reply to message 6 from robson
Hey there!


I also just got this bug and figured out it was because somewhere in the script a other error occured (even a notice error causes this error to show because you're using throw).

Atleast...that's what I understood about it, i'm not a pro at OOP or anything.

Anyways! The fix is below! (atleast, it works perfectly fine for me!)

Find line: if ($this->ThrowExceptions) {
(Should be at line 1509 of version 2.5)

Now...change the whole line to this:

if ($this->ThrowExceptions) {
if(isset($this->error_desc) && $this->error_desc != NULL) {
throw new Exception($this->error_desc.' '.__LINE__);
}
}


It's a bit hacky I believe...but it works totally fine, you still get normal errors and stuff.

The issue is that if error_desc is empty (which it is when your query runs fine..) php somehow throws up a error...

Hope I've helped! :)

  8. Re: Bug with $db->Close()   Reply   Report abuse  
Picture of Jeff Williams Jeff Williams - 2010-12-23 16:17:58 - In reply to message 7 from Vincent
great find! i added your code and i like the line number addition