简体   繁体   English

PHP / MySQL-错误->“字段列表”中的“未知列”

[英]PHP/MySQL - Error --> Unknown column '' in 'field list'

I have read many of the posts regarding this "Unknown column '' in 'field list'" error I am getting when I try to INSERT INTO my database. 当我尝试将数据库插入到数据库中时,我读到了很多有关“字段列表”中“未知列”错误的信息。 All the posts I read, the error includes the column name that seems to have the problem. 我读过的所有帖子,错误都包括似乎有问题的列名。 In my case it is just ''... nothing! 就我而言,这只是“ ...什么都没有!

I hand code everything because I am not a "real" programmer and I use free stuff such as Notepad++. 我手工编写所有代码,因为我不是一个“真正的”程序员,并且使用了诸如Notepad ++之类的免费软件。 I don't have any debugging tools. 我没有任何调试工具。

Here is my code below. 这是下面的代码。 I have many repetive lines so I cut some out. 我有很多重复的行,所以我删掉了一些。

<?php
//Connect to database
include("../ConfigFiles/ConnectDB_local_i.php");

//Populating the variables
$InvoiceNo = $_POST["nInvoiceNo"];
$InvoiceDate = $_POST["nDate"];
$ClientName = $_POST["nName"];
$ClientAddress = $_POST["nAddress"];
$ClientPhone = $_POST["nPhone"];
$ClientEmail = $_POST["nEmail"];
$STotalTaxable = $_POST["nSTotalTax"];
$TPS = $_POST["nTPS"];
$TVQ = $_POST["nTVQ"];
$STotalNonTaxable = $_POST["nSTotalNoTax"];
$TotalInvoice = $_POST["nTotalNet"];
$DescLine_1 = $_POST["nDescLine1"];
            ---I cut lines 2 though 14.  They are all the same ---
$DescLine_15 = $_POST["nDescLine15"];
$TotalLine_1 = $_POST["nTotalLine1"];
           ---I cut lines 2 though 14.  They are all the same ---
$TotalLine_15 = $_POST["nTotalLine15"];

//Writting to DB
echo "<br>I wrote to the database<br>";
$query = "INSERT INTO `invoicedata_table` 
            (`InvoiceNo`, 
            `InvoiceDate`, 
            `ClientName`, 
            `ClientAddress`,  
            `ClientPhone`,  
            `ClientEmail`,
            `STotalTaxable`,
            `TPS`,
            `TVQ`,
            `STotalNonTaxable`,
            `TotalInvoice`,
            `DescLine_1`,
           ---I cut lines 2 though 14.  They are all the same ---
            `DescLine_15`,
            `TotalLine_1`,
           ---I cut lines 2 though 14.  They are all the same ---
            `TotalLine_15`) 
        VALUES 
            ('$InvoiceNo',
            '$InvoiceDate',
            '$ClientName',
            '$ClientAddress',
            '$ClientPhone',
            '$ClientEmail',
            '$STotalTaxable',
            '$TPS',
            '$TVQ',
            '$STotalNonTaxable',
            '$TotalInvoice',
            `$DescLine_1`,
           ---I cut lines 2 though 14.  They are all the same ---
            `$DescLine_15`,
            `$TotalLine_1`,
           ---I cut lines 2 though 14.  They are all the same ---
            `$TotalLine_15`);";
$mysqli->query($query) or die($query.'<br />'.$mysqli->error);

//Close the DB connection
$mysqli->close();

?> ?>

I have faced the same challenge for 2 days and the solution i have found is to change the COLLATION of my sql database. 我已经面临了2天的相同挑战,而我发现的解决方案是更改sql数据库的集合。 I was mixing latin general ci with utf8 general ci. 我将拉丁通用ci与utf8通用ci混合在一起。 I just changed everything in phpmyadmin to utf8 general ci and the problem was solved. 我只是将phpmyadmin中的所有内容更改为utf8 general ci,问题已解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM