So I have a php script that is supposed to insert all of the stuff that comes in through the form into a database. What I have done is stored all the values in an array and then I am attempting to implode them while inserting into a table just so I can handle them all at once.
However I keep getting this error and I do not know why:
Error: Unknown column 'test' in 'field list'
What seems like is happening is the implode function is giving off the actual values that are entered in the form (rather than the column names) and the the insert function is trying to insert them in the columns, when really this should not be happening because $profileCols is just an array of strings that represent the column names.
Could somebody help me out, here is where you can find the form and error.
<?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);
?>