2013-04-28 17 views
-1

我是一個新的PHP。用這個試驗很多。我寫了另一個代碼。但它顯示了第26行的錯誤。我無法找到問題。請檢查並告訴我問題是什麼。 result.php不能找到第6行上的錯誤

<?php 
if (isset ($_POST["name"])){ 
    $name=$_POST["name"]; 
} 
if(isset ($_POST["yob"])){ 
    $yob=(int) $_POST["yob"]; 
} 
if(isset ($_POST["wifename"])){ 
    $wifename=$_POST["wifename"]; 
} 
if(isset ($_POST["wyob"])){ 
    $wyob= (int) $_POST["wyob"]; 
} 
$currentyear=date("Y"); 
if($yob>=$currentyear){ 
    echo "Sorry {$name} you have not born yet."; 
} 
if($currentyear>$yob){ 
    $husbandage=$currentyear-$yob; 
} 
if($wyob>=$currentyear){ 
    echo "Sorry {$name} your mother in law is still virgin."; 
} 
else{$wifeage=$currentyear-$wyob;} 
if($husbandage>$wifeage){ 
    echo "You are {"$husbandage-$wifeage"} years older than your wife"; 
} 
if($husbandage<$wifeage){ 
    echo "You are {$wifeage-$husbandage} years older than your wife";} 
    if($husbandage==$wifeage){ 
     echo "You and your wife are same age";} 

?> 

agecalculator.php

<html> 
<title>Age Difference Calculator</title> 
<body> 
<form action="result.php" type="post"> 
    Your Name: <input type="text" name= "name"><br/> 
    Year Of Birth: <input type= "text" name:"yob"><br/> 
    Your Wife's Name: <input type="text" name="wifename"><br/> 
    Your Wife's Year Of Birth: <input type="text" name="wyob"><br/> 
    <input type="submit"> 
</form> 
</body> 
</html> 
+3

有什麼錯誤? – Dinesh 2013-04-28 23:50:00

+2

什麼是'{int} $ _ POST [「yob」];'?嘗試'(int)$ _ POST [「yob」]' – mash 2013-04-28 23:50:18

+0

好吧,我修好了。但現在問題出現在第24行。請告訴我我在第24行發生了什麼錯誤? – supto 2013-04-28 23:59:37

回答

8

問題是

{int} 

應該

(int) 
3

也許你應該改變

$yob={int} $_POST["yob"]; 

對於這一點:

$yob=(int) $_POST["yob"];