2017-05-25 113 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

你想從這段代碼中得到什麼?只是執行查詢或查找文件並將其上載到文件夾中? –

相關問題