致命错误:未捕获PDOException:SQLSTATE [42000]:语法错误或访问冲突:1064

时间:2017-05-25 17:30:25

标签: php

我为这段代码花了很多时间。我收到了这个错误。 这是我得到的完整错误。 致命错误:未捕获PDOException:SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法中有错误;检查与您的MariaDB服务器版本相对应的手册,以便在/Applications/XAMPP/xamppfiles/htdocs/efiling/editform.php的第5行'from_to ='mr kingkong motheryucker'details ='asasasas''附近使用正确的语法: 61堆栈跟踪:#0 /Applications/XAMPP/xamppfiles/htdocs/efiling/editform.php(61):在/ Applications / XAMPP / xamppfiles / htdocs / efiling / editform中抛出的PDOStatement-> execute()#1 {main}第61行的.php

<?php
error_reporting( ~E_NOTICE );

    require_once 'dbconfig.php';

    if(isset($_GET['edit_id']) && !empty($_GET['edit_id']))
    {
        $id = $_GET['edit_id'];
        $stmt_edit = $DB_con->prepare('SELECT * FROM upload WHERE id =:uid');
        $stmt_edit->execute(array(':uid'=>$id));
        $edit_row = $stmt_edit->fetch(PDO::FETCH_ASSOC);
        extract($edit_row);
    }
    else
    {
        header("Location: index.php");
    }

    if(isset($_POST['btn_save_updates']))
    {
    $title = $_POST['title'];// file title
    $date = $_POST['date'];// file date
    $ref = $_POST['ref'];// file ref
    $from_to = $_POST['from_to'];// person incharge
    $details = $_POST['details'];// details
    $location = $_POST['location'];// file location
    $status = $_POST['status'];// file status   

  $name=$_FILES['photo']['name'];
  $size=$_FILES['photo']['size'];
  $type=$_FILES['photo']['type'];
  $temp=$_FILES['photo']['tmp_name'];

        // if no error occured, continue ....
    $stmt = $DB_con->prepare('UPDATE upload 
                                         SET title=:title,  
                                             date=:date, 
                                             ref=:ref 
                                             from_to=:from_to 
                                             details=:details 
                                             location=:location 
                                             status=:status 
                                             name=:name 
                                       WHERE id=:id');
            $stmt->bindParam(':title',$title);
            $stmt->bindParam(':date',$date);
            $stmt->bindParam(':ref',$ref);
            $stmt->bindParam(':from_to',$from_to);
            $stmt->bindParam(':details',$details);
            $stmt->bindParam(':location',$location);
            $stmt->bindParam(':status',$status);
            $stmt->bindParam(':name',$name);
            $stmt->bindParam(':id',$id);

            if($stmt->execute()){
                ?>
                <script>
                alert('Successfully Updated ...');
                window.location.href='view.php';
                </script>
                <?php
            }
            else{
                $errMSG = "Sorry Data Could Not Updated !";
            }




    }

?>

1 个答案:

答案 0 :(得分:3)

你忘记了逗号:

 $stmt = $DB_con->prepare('UPDATE upload 
                                     SET title=:title,  
                                         date=:date, 
                                         ref=:ref ,
                                         from_to=:from_to ,
                                         details=:details ,
                                         location=:location ,
                                         status=:status ,
                                         name=:name
                                   WHERE id=:id');