所以我有一个PHP脚本,应该将所有通过表单进入的东西插入到数据库中。我所做的是将所有的值存储在一个数组中,然后我试图在插入表时将它们内爆,以便我可以一次处理它们。插入VALUES不能正常工作(以及implode功能)
但是我不断收到这个错误,我不知道为什么:
错误:在“字段列表”未知列“测试”
什么似乎正在发生的事情是破灭功能给关闭在表单中输入的实际值(而不是列名)和插入函数试图将它们插入到列中,但实际上这不应该发生,因为$ profileCols只是表示列名称的字符串数组。
有人可以帮助我,这里是你可以找到窗体和错误。
<?php
$profile = $_POST["profile"];
$requestedAmount = $_POST["requestedAmount"];
$currentBalance = $_POST["currentBalance"];
$creditScore = $_POST["creditScore"];
$timeInBusiness = $_POST["timeInBusiness"];
$avgMonthly = $_POST["avgMonthly"];
$noBankDeposits = $_POST["noBankDeposits"];
$avgBalance = $_POST["avgBalance"];
$monthlyNSF = $_POST["monthlyNSF"];
$industryType = $_POST["industryType"];
$endingBalance = $_POST["endingBalance"];
$profileValues = array("$profile", "$requestedAmount", "$currentBalance", "$creditScore", "$timeInBusiness", "$avgMonthly", "$noBankDeposits", "$avgBalance", "$monthlyNSF", "$industryType", "$endingBalance");
$profileCols = array('profile', 'requestedAmount', 'currentBalance', 'creditScore', 'timeInBusiness', 'avgMonthly', 'noBankDeposits', 'avgBalance', 'monthlyNSF', 'industryType', 'endingBalance');
if (isset($profileValues))
{
$entry = 'INSERT INTO profileBuilder (' . implode(",", $profileCols) .') VALUES (' . implode (",", $profileValues) . ')';
} else {
echo "failure buddy!";
}
if (!mysqli_query($con,$entry))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added";
mysqli_close($con);
?>
在您提供的任何代码中没有列'test'。你也开放SQL注入。 – Kermit
你很容易受到SQL注入攻击:http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php – Lorenz
多数民众赞成我说什么,即时通讯不试图把测试进入柱!测试将是我正在进入一个表格 – Philip