I’ve been battling with this for a while, I’m not familiar with PHP syntax, here’s my code:
$eventArray = array($this->ReturnLastRecordId() + 1, $managerid, $title, $description, $category, $address, $location, $startdate, $starttime, $enddate, $endtime, $price, $endofticketdate, $totalseats, $totalseats);
$sql = "INSERT INTO event (eventid, managerid, title, description, category, address, location, startdate, starttime, enddate, endtime, price, endofticketdate, totalseats, totalseats)";
$data->StoreData($eventArray, $sql);
In the function:
public function StoreData($dataArray, $sqlquery)
{
include 'config.php';
$i = count($dataArray);
echo $i;
switch ($i) {
case 15:
mysql_query($sqlquery . "VALUES (" . '$arraydata[0]' , '$arraydata[1]', '$arraydata[2]', '$arraydata[3]', '$arraydata[4]', '$arraydata[5]', '$arraydata[6]', '$arraydata[7]', '$arraydata[8]', '$arraydata[9]', '$arraydata[10]', '$arraydata[11]', '$arraydata[12]', '$arraydata[13]', '$arraydata[14]' . ")", $con) or die (mysql_error());
mysql_close($con);
break;
}
}
Obviously I’ve checked the number of parameters multiple times, including the database, but still the parameter count get thrown :(.
You are not concatenating the SQL string. Your code passes multiple separate PHP function parameters.
The most lazy fix would be:
I would advise that you enclose the whole single string that mysql_query expects in double quotes, and then use string interpolation within. Avoid manual
.concatenation.