2013-04-21 48 views
-1

最近我的webserver從PHP v.4遷移到v.5.3。我知道,我知道,很長一段時間:)由於v.4到v5遷移,PHP腳本不再起作用

但是現在當用戶輸入所需的數據時,我的一些腳本不顯示結果。這裏是腳本:

<?php 
if ($ok) { 

    if ($heightft == "" || $heightin == "" || $weight == "") { 
     $error = "<br><FONT COLOR=#FF0000>One of the fields above was not completed.</FONT><br>"; 
    } else { 
     $bmi = $weight * 703/(($heightft * 12 + $heightin) * ($heightft * 12 + $heightin)); 
     $bmiString = number_format($bmi,2,".",""); 
     echo "<table border='1' cellpadding='10' bordercolor='0000FF'><tr><td><strong>Your BMI is: " . $bmiString; 
echo "<br><br></strong>"; 

     if ($bmi <= 18.50) { 
      echo "You are classified as <strong>Underweight</strong>."; 
     } elseif ($bmi <= 24.99) { 
      echo "You are classified as <strong>Normal</strong>."; 
     } elseif ($bmi <= 29.99) { 
      echo "You are classified as <strong>Overweight</strong>."; 
     } else { 
      echo "You are classified as <strong>Obese</strong>.</td></tr></table></bordercolor>"; 
     }  
    } 
} 

?> 

<?php echo $error;?> 
+3

'$ ok'在哪裏設置? – hek2mgl 2013-04-21 20:27:00

+5

不要緊,升級PHP晚了,你*仍然*使用''? – 2013-04-21 20:32:16

回答

5

看起來像你期待register_globals上。這現在是默認關閉的。

您應該使用$_GET['heightft']$_POST['heightft']取決於窗體方法來訪問此數據。

+0

應該從'$ _GET ['var']'或'$ _POST ['var']'而不是'$ var'讀取的變量是:'ok','heightft','heightin'和'weight' 。 – drealecs 2013-04-21 20:36:42

+0

感謝您的回覆。所以爲了澄清,我會改變:if($ heightft ==「」|| $ heightin ==「」|| $ weight ==「」)if($ _GET ['heightft'] ==「」|| $ _GET ['heightin'] ==「」|| $ _GET ['weight'] ==「」)?再次感謝 – user1745590 2013-04-21 20:58:57

+0

您可能需要編輯if($ ok){'to'if($ _GET ['ok']){'too。 – drealecs 2013-04-22 01:21:40