我正在尝试将CSV导入mySQL,我对此非常陌生,但据我所知,我已经完全遵循了another post on stackoverflow has said并且它仍然无效。
<?php
$servername = "localhost";
$username = "root";
$password = "password";
$dbname = "test";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$query = <<<eof
LOAD DATA INFILE 'hi.csv'
INTO TABLE testing
FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(firstname)
eof;
$db->query($query);
?>
如果有人能提供帮助,我们将不胜感激。使用当前代码,错误是“解析错误:语法错误,第24行(文件名)中的文件意外结束。但即使没有错误,它也不会将新数据放入mySQL。