UPDATE语法错误或访问冲突:1064

时间:2017-04-23 09:54:39

标签: php pdo

我确信它看起来代码的时间太长但我无法让我的数据库更新,每次调用以下错误:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `id`= '32'' at line 12

这是我的代码:

if(isset($_POST["EventUpdate"])) {
            $Event_Added = date("Y-m-d H:i:s");
            $Event_Added_By = $_SESSION['memberID'];
            $Event_Start_Time = $_POST["StartTimeHour"].":".$_POST["StartTimeMinute"];
            $Event_End_Time = $_POST["EndTimeHour"].":".$_POST["EndTimeMinute"];
            $Event_Start_Date = date("Y-m-d H:i:s", strtotime(str_replace('/', '-', $_POST["StartDate"])));
            $Event_End_Date = date("Y-m-d H:i:s", strtotime(str_replace('/', '-', $_POST["EndDate"])));
            $Event_Booking_Limit = $_POST["BookingLimit"];
                try {
                    $Event_Update_SQL = "UPDATE event_information
                    SET
                    `added`= :Added,
                    `added_by`= :AddedBy,
                    `type`= :Type,
                    `title`= :Title,
                    `start_time`= :StartTime,
                    `end_time`= :EndTime,
                    `start_date`= :StartDate,
                    `end_date`= :EndDate,
                    `booking_limit`= :BookingLimit,
                    WHERE `id`= :id";
                    $Event_Update = $dbconn->prepare($Event_Update_SQL);
                    $Event_Update->bindParam(':Added', $Event_Added, PDO::PARAM_STR);       
                    $Event_Update->bindParam(':AddedBy', $Event_Added_By, PDO::PARAM_STR); 
                    $Event_Update->bindParam(':Type', $_POST["Type"], PDO::PARAM_STR);
                    $Event_Update->bindParam(':Title', $_POST["Title"], PDO::PARAM_STR); 
                    $Event_Update->bindParam(':StartTime', $Event_Start_Time, PDO::PARAM_STR);   
                    $Event_Update->bindParam(':EndTime', $Event_End_Time, PDO::PARAM_STR);
                    $Event_Update->bindParam(':StartDate', $Event_Start_Date, PDO::PARAM_STR); 
                    $Event_Update->bindParam(':EndDate', $Event_End_Date, PDO::PARAM_STR);
                    $Event_Update->bindParam(':BookingLimit', $Event_Booking_Limit, PDO::PARAM_STR);
                    $Event_Update->bindParam(':id', $_GET["id"], PDO::PARAM_STR);
                        if($Event_Update->execute()) {
                            header( "Location: ".$_SERVER["REQUEST_URI"]."?id=".$_GET["id"]) ;
                        } else {
                            $Event_Message = "<span>Something went wrong with the Update!</span>";
                            $Event_Update->errorInfo();
                        } 
                    }
                catch(PDOException $e) {
                    echo $e->getMessage();
                }
        }

我无法弄清楚我做错了什么,我已经绑定了我的每一个字段,我认为我已经准备好了我的陈述,但不管我做了什么都不断给我留下同样的错误信息。< / p>

0 个答案:

没有答案