2013-11-25 58 views
1

使用我收到以下錯誤:MySQL服務器版本正確的語法近

"Error: 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 ' `DeweyEdition` 
BLOB NOT NULL, , `DeweyNumber` BLOB NOT NULL)' at line 1 
<br />Error No: 1064<br />ALTER TABLE tt_hj_import ADD COLUMN 
(`CountryOfPub` BLOB NOT NULL, , `DeweyEdition` BLOB NOT NULL, , 
`DeweyNumber` BLOB NOT NULL) in /var/www/system/database/mysql.php on line 50" 

我的代碼:

public function alterImportTable($new_fields) { 
    if (!empty($new_fields)) { 
     $sql = "ALTER TABLE " . DB_PREFIX . "hj_import ADD COLUMN "; 
     $fields_sql = array(); 
     foreach ($new_fields as $field) { 
      $fields_sql[] = '`' . $field . "` BLOB NOT NULL, "; 
     } 
     $sql .= '(' . implode(', ', $fields_sql) . ')'; 
     $sql = str_replace(',)', ')', $sql); 
     $this->db->query($sql); 
    } 
} 

我該如何解決這個問題?

+0

爲了緩解幫助您可以在粘貼之前,SQL的'' - >查詢「電話? – nrathaus

回答

1

我認爲這是在查詢一個額外的空間,嘗試NULL,這樣之後,除去,

$fields_sql[] = '`' . $field . "` BLOB NOT NULL "; 
+1

輝煌你的英雄它的作品感謝很多人。乾杯!!! – user2496631

0

你需要每列一個ADD COLUMN

+0

感謝您的回覆。 – user2496631

0

我有同樣的問題在我的計劃,我只是改變了查詢版

mysql_query($sql,$con) 

TO

mysqli_query($sql, $con) 
相關問題