我无法定义我的错误

时间:2015-04-22 16:41:47

标签: php sql

解析错误:语法错误,C:\ Program Files(x86)\ EasyPHP-DevServer-14.1VC11 \ data \ localweb \ ass1re \ create database.php在第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>

2 个答案:

答案 0 :(得分: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']))

答案 1 :(得分: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"){