我有一個這樣的查詢:SQL請求語法
$modifiedDate1 = date("F d Y H:i:s.", filemtime($file));
$query = "INSERT IGNORE INTO file (filename, modifiedDate1) VALUES ".implode(',', $filenames)."".$modifiedDate1."";
我有我的SQL語法錯誤我的第二個值,爲什麼呢?
錯誤:
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 'January 01 1970 01:00:00.' at line 1
如果它可以幫助整個代碼爲:
$pdo = new PDO('mysql:host=localhost;dbname=check', 'root', 'root');
if ($handle = opendir('check')) {
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
if($file!='.' && $file!='..') {
$filenames[] = "('".$file."')";
}
}
closedir($handle);
}
$modifiedDate1 = date("F d Y H:i:s.", filemtime($file));
/* insert new record into the table filenames with the filename */
$query = ("INSERT IGNORE INTO file (filename,modifiedDate1) VALUES ('".implode(',', $filenames)."".$modifiedDate1."')");
$stmt = $pdo->exec($query);
if (!$stmt) {
echo "\nPDO::errorInfo():\n";
print_r($pdo->errorInfo());
}
print "finished installing your files!";
此代碼是如果數據庫中已存在的文件的數據進行比較。
請編輯你的問題,並解釋更多。 – NimaNr
@NimaNr好的,那是做 – maevy