CSV导入phpMyadmin错误#1054缺少列,即使它在那里

时间:2017-04-09 22:59:44

标签: php pdo phpmyadmin mysql-error-1054 csv-import

感谢所有阅读此内容的人。我试过寻找过去几个小时的类似答案/解决方案。所有答案都是在人们手动导入数据时开始的,我使用CSV文件将其导入到我的表中。

这就是我的csv文件的外观。 CSV File

导入后,添加ID字段并使用AI为其指定一个主值,它看起来像这样: table structure

我可以轻松访问我的php文件中的Fault和ID选项卡,通过fetchAll(PDO :: FETCH_ASSOC)访问它们;代码。

但是,如果我将链接添加到SELECT语句,则会收到一条错误消息,指出字段不存在。

另请注意,尝试检查全文值会给出以下错误消息: enter image description here

但是,如果我尝试将视图选项更改为全文并再次双击该单元格,则不会收到任何错误消息: enter image description here

考虑到这一切,我很困惑,为什么它无法在数据库中找到Link字段,甚至认为它在同一个表中找到了ID和Fault单元格绝对精细。

非常感谢任何建议,谢谢。

1 个答案:

答案 0 :(得分:0)

Solution: Not really anything to do with PHPMyAdmin apart from the fact that when I've imported a CSV file, it has a Space next o Link.

With the help of user chris85 I've changed my loop to just an array and printed all of it. Spent good 10 minutes looking through it as it did not give me any error messages yet had the "Link" field. Turns out, when I've printed the results / saved them in the CSV file, I have accidentally added a Space ( ) before Link.

This was a major headache, but thank you for helping me figure this out @chris85 I've then altered my echo "<td>" . $forumDetail['Link'] . "</td>";

to have a space, like this :

 echo "<td>" . $forumDetail[' Link'] . "</td>";

And that printed the result absolutelly fine.

Once again, stackoverflow proves the importance of one empty space or a missed semicolon :)