Jump to content


Photo

Weird error with division by zero


  • Please log in to reply
8 replies to this topic

#1 oxez

oxez
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 03 August 2006 - 11:15 PM

Ok, so bascically what I'm currently doing is an error handler. I've created a Debugger class, and used set_error_handler() to use that class.

So, to test this, I've tried a mysql_connect() with wrong infos, my Debugger caught that, and displayed it the way I wanted.

I tried this explicetly (there are no variables involved in this math): echo 4/0;

On my windows server, my error handler catches it. On my linux server, it works. On my friend's server, it also works. But on my current webhost, it just doesn't work..

I get an error like: "Warning: Division by zero in Unknown on line 0" . Notice the "Unknown on line 0" part. Weird? Yes it is...

So, I tried that 4/0 thing without my Debugger class on my own machine as well, and I get what I'm supposed to get: "Warning: Division by zero in /media/stuff/www/zeal/index.php on line 14" . There are no "Unknown on line 0" there..

After all those tests, I tried to compare php.ini files on every server, and they all look the same. But, on my webhost, Zend Optimiser was installed. Maybe the optimiser could cause this weird thing, so I installed Zend Optimiser (tried versions 2 and 3) on my linux machine, and my code was still working. No success again.

So I'm asking for help here, I have no idea how to fix that, and google isn't being useful on that one..

Note: All the servers I tried my code run are running PHP 5.1.4 (latest), on Apache. Please also note that I used the same code everywhere (in fact, I use SVN, so I just had to checkout my repository).

Thanks in advance!


#2 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 04 August 2006 - 07:54 AM

probably cuz any thing divided my 0 = 0 :)

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 04 August 2006 - 10:41 AM

probably cuz any thing divided my 0 = 0 :)


Even in the 'new' math, anything divided by zero is infinity !

@oxez - does comparison of the phpinfo() on the servers show any significant differences?
Legend has it that reading the manual never killed anyone.
My site

#4 oxez

oxez
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 05 August 2006 - 01:48 AM

probably cuz any thing divided my 0 = 0 :)


Even in the 'new' math, anything divided by zero is infinity !

@oxez - does comparison of the phpinfo() on the servers show any significant differences?


No it doesn't show any difference when I compare their options that might be related to error handling.

And to BillyBoB. I know that. But did you read my post? I'm talking about differences between servers, I know that anything / 0 = 0. This is not a math problem, but an error handling......

#5 oxez

oxez
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 05 August 2006 - 05:18 AM

Ok, so I got a "temporary" solution from another forum.

When I use: echo (string) 4 / 0; it now writes the Filename + Line of the division by zero, and my error handler now catches the warning. I just need to know how to avoid having to add (string) for that...

#6 beamerrox

beamerrox
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts
  • LocationGrimshaw, Alberta, Canada

Posted 05 August 2006 - 06:42 AM

don't divide by zero?

#7 oxez

oxez
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 05 August 2006 - 04:31 PM

don't divide by zero?


Wow? I just said I want my error handler to catch it, since I'll use it to debug my code.

I know that divide by zero is BAD, but my problem is not there. I want to know WHY I have to type-cast (string) to get the wanted warning.


#8 beamerrox

beamerrox
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts
  • LocationGrimshaw, Alberta, Canada

Posted 05 August 2006 - 05:27 PM

just another PHP glitch, tell them about it on their support boards

#9 oxez

oxez
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 07 August 2006 - 08:15 PM

Okay. So I've tried about 5 or 6 php channels, each time explaining my problem, with no luck. I've tried other forums as well, still no luck.

I'm just bumping this, since I might get lucky with someone who could have missed my first post..

(PS: What did you mean by "their support board" ??)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users