2017-05-25 188 views
-2

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

<?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 !"; 
      } 




    } 

?> 

回答

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'); 
+0

但Ÿ我上传的文件并没有上传文件夹中保存?我忘了那里的东西吗? – aini

+0

我的意思是也更新我的HTML格式的文件。但它不存在于我的文件夹中(上传) – aini

+0

你想从这段代码中得到什么?只是执行查询或查找文件并将其上载到文件夹中? –

相关问题