更新表解析错误

时间:2013-03-01 17:02:27

标签: php mysql

概述: 我正在创建一个虚拟网站用于学习目的,因此它的功能主义者是基本的和安全的,不在议程上。

问题: 当我登录系统并单击编辑帐户按钮时,我收到此错误:

  

解析错误:语法错误,第104行的C:\ xampp \ htdocs \ eshop \ userEditAccount.php中的文件意外结束

userEditAccount.php文件:

<?php


session_start();



    require_once('userEditAccount.php');
    include('connect_mysql.php');


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

    $userid = $_SESSION['user_id'];

    $Newusername = $_POST['username'];
    $Newpassword = $_POST['password'];
    $Newfirstname = $_POST['first_name'];
    $Newlastname = $_POST['last_name'];
    $Newemail = $_POST['email'];



    $sql = "UPDATE users SET username='$Newusername', password='$Newpassword',
    first_name='$Newfirstname', last_name='$Newlastname WHERE user_id='$userid'";

    $result = mysql_query($sql)  or die("Query failed : " . mysql_error()); 

    if(!$result){
        exit("Error Ocured whilsd updating $ud_id record");
    }
    echo "Record $ud_id has been sucesfully updated";


mysql_close($con);

?>


<html>
<head>

<title>Edit Account</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>

    <div id="wrapper">
        <header><h1>E-Shop</h1></header>


        <article>
        <h1>Welcome</h1>

            <h1>Edit Account</h1>

        <div id="login">

                <ul id="login">

                <form method="post" name="editAccount" action="userEditAccount.php"  >
                    <fieldset>  
                        <legend>Fill in the form</legend>

                        <label>Select Username : <input type="text" name="username" /></label>
                        <label>Password : <input type="password" name="password" /></label>
                        <label>Enter First Name : <input type="text" name="first_name" /></label>
                        <label>Enter Last Name : <input type="text" name="last_name" /></label>
                        <label>Enter E-mail Address: <input type="text" name="email" /></label>
                    </fieldset>
                        <br />

                        <input name="Editsubmited" type="submit" submit="submit" value="Edit Account" class="button">

                </form>

                <?

                    echo $newrecord;
                ?>


                </div>
            <form action="userhome.php" method="post">
            <div id="login">
                <ul id="login">
                    <li>
                        <input type="submit" value="back" onclick="index.php" class="button">   
                    </li>
                </ul>
            </div>      



        </article>
<aside>
</aside>

<div id="footer">This is my site i Made coppyrights 2013 Tomazi</div>
</div>

</body>
</html>

查看代码一切看起来都是正确的,错误无意义意外结束文件.........

当我在单独的文件中使用php代码并将此文件与html文件链接时,我在php中的文件中得到相同的错误,因此我猜它与php有关....

任何建议Overflowers:....?

2 个答案:

答案 0 :(得分:4)

你没有关闭你的if:

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

为了防止将来出现此错误,请确保正确缩进代码,这样可以更轻松地找到属于一起的大括号并查看缺少的大括号。

答案 1 :(得分:0)

以下提到的if语句未关闭:

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

echo $newrecord;语句

之后关闭此函数