2K Posted May 12, 2009 Share Posted May 12, 2009 $f1 = 300; $y1 = 200; $yatk = 75; $fdef = 125; $y3 = $y * $y2; $f3 = $f * $f2; The code functions 100% fine when the numbers entered into the text box (which is where $y and $f come from) are odd. It will work fine if $y is even (20, 22, 24) and $f is the next number (21, 23, 25). If $y = ODD and $f = EVEN it won't work. And if it's 2 even numbers it won't work. So, question is: how do I get it to make... 1. 2 even numbers work 2. Odd ($y) and Even ($f) numbers work Link to comment https://forums.phpfreaks.com/topic/157750-solved-math-issue/ Share on other sites More sharing options...
Ken2k7 Posted May 12, 2009 Share Posted May 12, 2009 It should work regardless, but what's $y2 and $f2? Link to comment https://forums.phpfreaks.com/topic/157750-solved-math-issue/#findComment-832052 Share on other sites More sharing options...
2K Posted May 12, 2009 Author Share Posted May 12, 2009 In an error of mine (quickly trying to change the variables into something less...confusing), I seem to have put a 2 where the 1 should be. I know it _should_ work, but something is wrong. New updated code...still same issues... $f1 = 300; $y1 = 200; $yatk = 75; $fdef = 125; $y3 = $y * $y1; $f3 = $f * $f1; Link to comment https://forums.phpfreaks.com/topic/157750-solved-math-issue/#findComment-832058 Share on other sites More sharing options...
Daniel0 Posted May 12, 2009 Share Posted May 12, 2009 You'll probably have to elaborate on how it doesn't work. You're just multiplying two numbers. I don't see how that can fail unless you enter a huge number so it overflows. Link to comment https://forums.phpfreaks.com/topic/157750-solved-math-issue/#findComment-832090 Share on other sites More sharing options...
Maq Posted May 12, 2009 Share Posted May 12, 2009 It probably outputs 0 because $y and $f aren't ever initialized, they don't exist! $y3 = $y * $y1; $f3 = $f * $f1; Link to comment https://forums.phpfreaks.com/topic/157750-solved-math-issue/#findComment-832136 Share on other sites More sharing options...
Ken2k7 Posted May 12, 2009 Share Posted May 12, 2009 Maq, I don't think the OP post all of his code. $y and $f as stated came from some input fields. I assume he used the correct $_GET, $_POST, $_REQUEST or filter_input() to get the information. Link to comment https://forums.phpfreaks.com/topic/157750-solved-math-issue/#findComment-832143 Share on other sites More sharing options...
Maq Posted May 12, 2009 Share Posted May 12, 2009 Maq, I don't think the OP post all of his code. $y and $f as stated came from some input fields. I assume he used the correct $_GET, $_POST, $_REQUEST or filter_input() to get the information. Right, my bad, need to get some sleep... So OP, if there are 1 or more even numbers then it won't work...? Like everyone else said, you may want to post some more code and elaborate on what, "it won't work" means. Link to comment https://forums.phpfreaks.com/topic/157750-solved-math-issue/#findComment-832149 Share on other sites More sharing options...
2K Posted May 12, 2009 Author Share Posted May 12, 2009 After a bit of working on it on my own, I got it working by rewriting the echo statement a tad (that would display the answer). Thanks all who responded...sorry if I wasted anyone's time. Link to comment https://forums.phpfreaks.com/topic/157750-solved-math-issue/#findComment-832151 Share on other sites More sharing options...
Maq Posted May 12, 2009 Share Posted May 12, 2009 That's good to hear, do you mind sharing the final code? Link to comment https://forums.phpfreaks.com/topic/157750-solved-math-issue/#findComment-832325 Share on other sites More sharing options...
shamuraq Posted May 17, 2009 Share Posted May 17, 2009 he's probably worried on some patent leak... LoLxxx Link to comment https://forums.phpfreaks.com/topic/157750-solved-math-issue/#findComment-835832 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.