1
我有一個小的TXT(〜130 KB)我試圖導入,但給我的錯誤:「錯誤創建表:一個表必須至少有1列」LOAD DATA INFILE從TXT
if(mysql_num_rows(mysql_query("SHOW TABLES LIKE 'test'")) == 1){
$sql = "LOAD DATA INFILE 'file.txt' INTO TABLE test IGNORE 1 LINES";
if (mysqli_query($con,$sql)){
echo "Import successfull.";
}
else{
echo "Error importing: " . mysqli_error($con);
}
}
else{
$sql = "CREATE TABLE test";
if (mysqli_query($con,$sql)){
echo "Table created successfully";
}
else{
echo "Error creating table: " . mysqli_error($con);
}
}
txt的第一行是列名。我可以根據該名稱創建列嗎?或者我必須手動創建它們嗎? 謝謝!