jacomus Posted March 6, 2008 Share Posted March 6, 2008 I think it is probably something simple I am missing, I am fairly new to PHP and am putting together a page while doing different experimentation with the language. My problem is that I have a user input for two numbers from a drop down menu. $number1 is the variable from the first menu $number2 is the variable from the second menu $total = $number1 - $number2; However, I always seem to get $total = $number1 It completely ignores the subtraction. I.E. If $number1 is 15 and $number2 is 4 Hitting the send button will get $total = 15 and not the expected value of 11. Is there something I am, perhaps, missing? Link to comment https://forums.phpfreaks.com/topic/94755-math-not-working-im-really-messing-up-somewhere-and-i-am-not-sure-what-simple/ Share on other sites More sharing options...
Barand Posted March 6, 2008 Share Posted March 6, 2008 Looks like $number2 is always 0 for some reason. Can't do much more for you without seeing the code. Link to comment https://forums.phpfreaks.com/topic/94755-math-not-working-im-really-messing-up-somewhere-and-i-am-not-sure-what-simple/#findComment-485291 Share on other sites More sharing options...
conker87 Posted March 12, 2008 Share Posted March 12, 2008 $number2 is probably null then. Like Barand said, can we see your code. Link to comment https://forums.phpfreaks.com/topic/94755-math-not-working-im-really-messing-up-somewhere-and-i-am-not-sure-what-simple/#findComment-490639 Share on other sites More sharing options...
jacomus Posted March 18, 2008 Author Share Posted March 18, 2008 It's cool, I figured it out, newbie error, I was using = instead of ==. Thanks for considering my issue though. Link to comment https://forums.phpfreaks.com/topic/94755-math-not-working-im-really-messing-up-somewhere-and-i-am-not-sure-what-simple/#findComment-495033 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.