I fixed 
PHP Code:
<body>
<?php
$action = $_POST['action'];
if($action == 1) {
$eqString = $_POST['equation']; //Postdata stored into $eqString.
$eqString = ereg_replace(" ", "", $eqString); //Makes it so that if they put in " + " the code below won't change it into " + "
$eqString = ereg_replace("\+", " + ", $eqString); //Add spaces before and after +.
$eqString = ereg_replace("-", " - ", $eqString); //Add spaces before and after -.
$eqString = ereg_replace("\*", " * ", $eqString); //Add spaces before and after *.
$eqString = ereg_replace("/", " / ", $eqString); //Add spaces before and after /.
$pieces = explode(" ", $eqString); //Put each term or operator of $eqString and put int into an array in $pieces.
$i1 = 0; //Set first counting variable to 0.
$i2 = 0; //Set second counting variable to 0.
foreach ($pieces as $array) { //This works for each variable in the array $pieces.
if (($array == "+") || ($array == "-") || ($array == "*") || ($array == "/")) { //Checks to see if the current variable is +. //If so, then it sets the current operator variable as +.
$operator[$i1] = $array;
//echo $operator[$i1]."<br>"; //Test
$i1++; //Adds one to the first counting number.
} elseif ($array >= 0) { //Checks to see if the current variable is a number.
$term[$i2] = $array; //If so, then it sets the current term variable as that number.
//echo $term[$i2]."<br>"; //Test
$i2++; //Adds one to the second counting number.
} else {
$answer = NULL; //Otherwise, it returns NULL.
}
}
//print_r($term); //Test
//print_r($operator); //Test
//function smath(&$term, &$operator, &$answer) {
//echo $operator[0]; //Test
$key1 = 0;
$key2 = 1;
$answer = $term[0];
while(array_key_exists($key1, $operator)) {
//echo "operator[".$key1."]: ".$operator[$key1]."<br>";
//echo "answer: ".$answer."<br>";
if(array_key_exists($key2, $term)) {
//echo "term[".$key2."]: ".$term[$key2]."<br>";
if ($operator[$key1] == "+") {
$answer = $answer + $term[$key2];
//echo $answer; //Test
} elseif ($operator[$key1] == "-") {
$answer = $answer - $term[$key2];
//echo $answer; //Test
} elseif ($operator[$key1] == "*") {
$answer = $answer * $term[$key2];
//echo $answer; //Test
} elseif ($operator[$key1] == "/") {
$answer = $answer / $term[$key2];
//echo $answer; //Test
} else {
$answer = NULL;
}
}
$key1++;
$key2++;
}
//}
}
echo "<br>The Answer For ". $eqString." is ".$answer.".<br><hr>";
?>
<form name="calculator" action="calcFrame.php" target="_self" method="POST">
<fieldset>
<legend>Calculator: (Fixed By TOB)</legend>
<input type="text" name="equation" maxlength="31"/>
<input type="hidden" name="action" value="1">
<input type="submit" value="Enter" />
<p>Note: This calculator does not follow order of operations.</p>
</fieldset>
</form>
</body>