Current location: Hot Scripts Forums » Programming Languages » PHP » Warning: Division by zero


Warning: Division by zero

Reply
  #1 (permalink)  
Old 03-24-06, 02:27 PM
brian110872 brian110872 is offline
New Member
 
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Warning: Division by zero

Hello,

Im get the following error message:

Warning: Division by zero in /home/find-a-w/public_html/bmi.php on line 16
PHP Code:



<?

if (isset($X2))
{



echo ((
$Y2 703) / ($X2 $X2));


}



?>
The value for Y2 is 200 and the value for X2 is 71.

Anyone have any ideas?

Thank You,
Brian
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-24-06, 02:41 PM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
tested it and it works fine, you obviously have not set X2 or Y2 previously in the script! try this instead:
PHP Code:

if (isset($X2) && isset($Y2)) 

__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-24-06, 02:48 PM
brian110872 brian110872 is offline
New Member
 
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Hello FiRe,

You're right. What I ment to say is that I get that message when the fields are not set. I tried your way and I'm still getting the error.

Brian
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 03-24-06, 03:51 PM
Patiek Patiek is offline
Wannabe Coder
 
Join Date: Nov 2003
Posts: 165
Thanks: 0
Thanked 0 Times in 0 Posts
You shouldn't be using isset alone. Instead, use other alternatives such as floatval:

PHP Code:

<?php

if(floatval($X2) != 0)
{
    echo ((
$Y2 703) / ($X2 $X2)); 
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
unknown problem - probably $session issue clantron PHP 6 03-19-06 02:36 PM
Warning: mysql_connect() wzzly PHP 7 02-17-06 06:09 AM
Warning: Division by zero in What does it mean? xxvatarxx PHP 5 02-04-06 02:05 PM
Warning: Wrong parameter count... Tim Mousel PHP 5 01-23-06 01:10 PM
Warning: session_start(): Cannot send session cache limiter jozin PHP 4 07-13-05 12:47 AM


All times are GMT -5. The time now is 05:11 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.