2015-04-22 28 views
-4

解析錯誤:語法錯誤,C:\ Program Files(x86)中的文件意外結束\ EasyPHP-DevServer-14.1VC11 \ data \ localweb \ ass1re \ create line.php on line 166我無法定義問題。一一查一查,但找不到。對不起,問我無法定義我的錯誤

<html> 
<head> 
</head> 
<body> 
<form action="first.php" method="post"> 
First Name: <input type="text" name="fName"> 
Second Name: <input type="text" name="sName"> 
Address : <input type="text" name="add"> 
Country/Region : <input type="text" name="country"> 
Gender : <input type="radio" name="gender" value="male" checked>Male 
     <input type="radio" name="gender" value="female" checked>Female 
Ic/No : <input type="text" name="ic"> 
Email : <input type="text" name="email"><br/> 
Period : <input type="text" id="period" name="period"> 
<select name="" onChange="combo(this,'period')"> 
    <option>4 days 3 night</option> 
    <option>5 days 4 night</option> 
    <option>6 days 5 night</option> 

</select> 

Place : <input type="text" id="place" name="place"> 
<select name="" onChange="combo(this,'place')"> 
    <option>London</option> 
    <option>Bali</option> 
    <option>Kuala Lumpur</option> 
</select> 

Room :<input type="text" id="room" name="room"> 
<select name="" onChange="combo(this,'room')"> 
    <option>First Class</option> 
    <option>Premium Class</option> 
</select> 

if (period ="4 days 3 night") 
{ 
    if (place ="London"){ 

     if(room="First Class"){ 
     <name="price" value="4500"> 
     }elseif (room="Premium Class"){ 
     <name="price" value="3500"> 
     } 
    }elseif(place ="Bali") 
     { 


      if(room="First Class"){ 
      <name="price" value="3500"> 
      }elseif (room="Premium Class"){ 
      <name="price" value="2500"> 
      } 
     } 
    }elseif(place ="Kuala Lumpur"){ 


      if(room="First Class"){ 
      <name="price" value="1500"> 
      }elseif (room="Premium Class"){ 
      <name="price" value="1500"> 
      } 
     } 
    } 
} 
if (period ="5 days 4 night") 
{ 
    if (place ="London"){ 

     if(room="First Class"){ 
     <name="price" value="5500"> 
     }elseif (room="Premium Class"){ 
     <name="price" value="4500"> 
     } 
    }elseif(place ="Bali") 
     { 


      if(room="First Class"){ 
      <name="price" value="4000"> 
      }elseif (room="Premium Class"){ 
      <name="price" value="3500"> 
      } 
     } 
    }elseif(place ="Kuala Lumpur"){ 


      if(room="First Class"){ 
      <name="price" value="2000"> 
      }elseif (room="Premium Class"){ 
      <name="price" value="1000"> 
      } 
     } 
    } 
} 
if (period ="6 days 5 night") 
{ 
    if (place ="London"){ 

     if(room="First Class"){ 
     <name="price" value="7500"> 
     }elseif (room="Premium Class"){ 
     <name="price" value="6000"> 
     } 
    }elseif(place ="Bali") 
     { 


      if(room="First Class"){ 
      <name="price" value="5500"> 
      }elseif (room="Premium Class"){ 
      <name="price" value="4000"> 
      } 
     } 
    }elseif(place ="Kuala Lumpur"){ 


      if(room="First Class"){ 
      <name="price" value="3500"> 
      }elseif (room="Premium Class"){ 
      <name="price" value="2000"> 
      } 
     } 
    } 
} 
<input type="submit" name="submit"> 
</form> 

<?php 
if (isset($_POST['submit'])) 
{ 


    $con = mysqli_connect('localhost','root',''); 
    if (!$con){ 
    die("Can not connected:" . mysql_error()); 
    } 

    if (mysqli_query($con,'CREATE DATABASE booking')){ 

    }else echo "Error: " . mysql_error(); 

    mysql_select_db($con,"booking"); 
$sql = 'CREATE TABLE book (
firstName varchar(20), 
secondNamee varchar(20), 
address varchar(20), 
gnder varchar(10), 
icNo int, 
region varchar(20), 
e-mail varchar (20), 
day varchar (20), 
rmm varchar (20), 
plce varchar (20), 
prce int 
)'; 
if(mysqli_query($sql,$con)){ 
}else { 
    echo"error creating table : " . mysqli_error($con); 
} 
$sql1 = "INSERT INTO book(firstName,secondNamee,address,gnder,icNo,region,e-mail,day,rmm,plce,prce) VALUES('$_POST(fName)','$_POST(sName)','$_POST(add)','$_POST(email)','$_POST(ic)','$_POST(country)','$_POST(room)','$_POST(place)','$_POST(period)','$_POST(gender)','$_POST(price)')"; 
    mysqli_query($sql1,$con); 
    mysqli_close($con); 
?> 

</body> 
</html> 
+3

(1) if(isset($ _ POST ['submit']))' – Sean

+1

Act'if(period =「4 days 3 night」)...'blocks(2)missing closing bracket'}'最終你的代碼中會有Un-Matched的'{'和'}'括號。使用正確的代碼縮進,你將能夠看到缺少的東西。此外,如果這是PHP代碼,您需要將PHP代碼包裝在適當的標籤中'' – RiggsFolly

+0

另外PHP變量應該以'$'開始,即'if($ period =「4 days 3 night」)' – RiggsFolly

回答

1

if (period ="4 days 3 night")必須在<?php標籤!
此外,您的情況是錯誤的!使用==進行比較!
每個變量名稱前失蹤$
應該看起來像:

<?php 
if ($period =="4 days 3 night") 
{ 
    if ($place =="London"){ 

     if($room=="First Class"){?> 
     <name="price" value="4500"> 
<?php 
     }elseif ($room=="Premium Class"){ 
+1

如果這些塊是php代碼,那麼OP在每個變量上缺少'$'。 – Sean

+0

事實上,我編輯,thx;) – Random

3

在你的代碼

if (isset($_POST['submit'])) 
{ 


    $con = mysqli_connect('localhost','root',''); 
    if (!$con){ 
    die("Can not connected:" . mysql_error()); 
    } 

    if (mysqli_query($con,'CREATE DATABASE booking')){ 

    }else echo "Error: " . mysql_error(); 

    mysql_select_db($con,"booking"); 
$sql = 'CREATE TABLE book (

我的事情你忘了關閉的}的一部分if (isset($_POST['submit']))

+2

仔細看,代碼 – RiggsFolly

+0

後有很多不匹配花括號,它後來它解析錯誤:語法錯誤,意外的'<'在C:\ Program Files文件(x86)\ EasyPHP-DevServer- 14.1VC11 \ data \ localweb \ ass1re \在第40行創建database.php =