【问题标题】:Updating table parse error [closed]更新表解析错误[关闭]
【发布时间】:2013-03-01 17:02:26
【问题描述】:

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

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

解析错误:语法错误,第 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:....?

【问题讨论】:

  • 天啊,我正在学习的人,我正在尝试在增强代码之前建立基本功能,这个网站永远不会上线。我非常了解安全问题和 SQL 注入问题。
  • 如果我发布一个问题来获得帮助并学习一些东西,而所有这些“聪明的人”寻找任何不喜欢某事的理由,这很难学习。就像每个人从一开始就让事情变得完美!!!!
  • 好吧,我不同意@MikeB,我是一名 C++ 程序员,从代码完全增强和发布正版之前的经验来看......代码在开发,在我看来,最大的错误是从一开始就尝试开发 PERFECT 软件,这是当项目失败、资金耗尽并且永远无法完成时,这就是程序员做原型和测试版的原因
  • 希望@MikeB 会让你开心 $newPassword = stripslashes(mysql_real_escape_string($_POST["password"]));

标签: php mysql


【解决方案1】:

你没有关闭你的 if:

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

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

【讨论】:

  • ok thx 工作 faceslap 但是现在当我提交查询时没有弹出错误但数据库中没有发生任何更改
【解决方案2】:

下面提到的if语句没有关闭:

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

echo $newrecord; 语句之后关闭这个函数

【讨论】:

  • ok thx 工作 faceslap 但是现在当我提交查询时没有弹出错误但数据库中没有发生任何更改
  • 在更新部分尝试这些行... if (!mysql_select_db($db_name, $db_con)){} $result=mysql_query($query, $db_con); $rowcount=@mysql_num_rows($result); if ( $rowcount > 0 ) -> 那么你的更新成功了
猜你喜欢
  • 2014-11-08
  • 1970-01-01
  • 1970-01-01
  • 2015-03-04
  • 2011-09-24
  • 2016-05-22
  • 2010-11-18
  • 2013-02-08
  • 2014-04-21
相关资源
最近更新 更多