Old 12-08-2007   #1 (permalink)
Registered User
 
Join Date: Oct 2007
Posts: 43

Send a message via MSN to Neo824
Exclamation PHP Calculator Mini-Project | Help

[PROBLEM SOLVED]

I'm working on a mini PHP project. It's a calculator (as stated in the title). For some reason, it isn't working correctly. It isn't doing the calculations properly, my code is provided below.

Link - www.neo-productions.com/test/php/calculator.php
Example of use - 1 [First Input Box] - [Second Input Box] 1 [Third Input Box]

calculator.php
Code:
<html>
<!-- BEGIN Header Information (Title, Style, ETC) -->
<head>
<style type="text/css">
<!--
input.integer_feild {
width: 20px;
text-align: center;
}

input.operation_feild {
width: 15px;
text-align: center;
}
-->
</style>

<title>Neo Productions - PHP Calculator</title>
</head>
<!-- END Header Information -->

<!-- BEGIN Body Information -->
<body>
<!-- First Feild -->
<form method="post" action="calculate.php">
<input class="integer_feild" type="text" name="First_Feild"/>
<!-- Operation Feild -->
<input class="operation_feild" type="text" name="Operation_Feild"/>
<!-- Second Feild -->
<input class="integer_feild" type="text" name="Second_Feild"/>
<!-- Calculate Button -->
<input type="submit" name="Calculate" value="Calculate"/>
</form>
</body>
<!-- END Body Information -->
</html>
calculate.php
Code:
<html>

<head>
</head>

<body>
<?
#BEGIN Variable Declarations & Initializations.
$First_Integer = $_POST['First_Feild'];
$Operator = $_POST['Operation_Feild'];
$Second_Integer = $_POST['Second_Feild'];
#END Variable Declarations & Initializations.

switch ($Operator){
#If $Operator is equal to "/" then divide $First_Integer by $Second_Integer.
case "/":
echo ($First_Integer / $Second_Integer);

#If $Operator is equal to "*" then multiply $First_Integer by $Second_Integer.
case "*":
echo ($First_Integer * $Second_Integer);

#If $Operator is equal to "-" then subtract $Second_Integer from $First_Integer.
case "-":
echo ($First_Integer - $Second_Integer);

#If $Operator is equal to "+" then add $First_Integer and $Second_Integer.
case "+":
echo ($First_Integer + $Second_Integer);
}
?>
</body>

</html>
All suggestions will be highly valued. Thank you!

- Neo

Last edited by Neo824; 12-09-2007 at 02:23 PM.
Neo824 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-08-2007   #2 (permalink)
Janitor of Lunacy
 
tamlin's Avatar
 
Join Date: May 2006
Location: Sitting in the Wishing Chair
Posts: 4,593

The link you posted is asking for a user name and password.
__________________


Religion: It's all fun and games until someone gets burned at the stake...
tamlin is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-08-2007   #3 (permalink)
Registered User
 
Join Date: Oct 2007
Posts: 43

Send a message via MSN to Neo824
Quote:
Originally Posted by tamlin View Post
The link you posted is asking for a user name and password.
Oops! Let me edit .htaccesss - The password is removed.

P.S
I think I figured out what my problem is. I think I should use the eval();...
I am going out now, so I'll test it out when I come back. :]
Neo824 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-09-2007   #4 (permalink)
Janitor of Lunacy
 
tamlin's Avatar
 
Join Date: May 2006
Location: Sitting in the Wishing Chair
Posts: 4,593

Now I'm getting a 404 Not Found message from that link.
__________________


Religion: It's all fun and games until someone gets burned at the stake...
tamlin is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-09-2007   #5 (permalink)
Registered User
 
Join Date: Oct 2007
Posts: 43

Send a message via MSN to Neo824
Quote:
Originally Posted by tamlin View Post
Now I'm getting a 404 Not Found message from that link.
Oh! I forgot to update. I don't have a problem anymore...I decided to use the eval(); function to solve my problem. Thanks everyone! =]

My calculator: Neo Productions - PHP Calculator

- Neo
Neo824 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Zapp Brannigan’s Biorust Community Collaboration Project 1.0 Zapp Brannigan General Discussions 30 06-04-2007 11:31 PM
PHP in HTML ultranet HTML / PHP / ASP / JS 3 01-04-2007 09:07 AM
Ajax and PHP sanjitster HTML / PHP / ASP / JS 2 06-03-2006 04:22 AM
Pro's and Con's to Upgrading PHP pipersdragon HTML / PHP / ASP / JS 1 12-29-2005 11:43 PM
Digital's Quick and Dirty Guide to PHP Order HTML / PHP / ASP / JS 15 05-05-2004 01:18 AM


All times are GMT +1. The time now is 11:37 PM.
Content Relevant URLs by vBSEO 3.2.0 RC7

Design & Content © BioRUST 2007 :: PRIVACY STATEMENT :: LEGAL INFORMATION :: ADVERTISING MEDIA KIT