Here is my code snippet:
$db = @mysql_select_db($db_name, $connection) or die ("Could not select database.");
//Array from select box
$count=count($category_array);
for ($i=0; $i<$count; $i++) {
$category_options = implode(',', $category_array);
}
echo "<br>$category_options";
$sql = "INSERT INTO $table_name (id, cname, caddress1, caddress2, caddress3, ccity, cstate, czip, ccountry, ctel, cfax, fname, email, mtype, listing_type, category_array[]) VALUES
(\"\",\"$cname\",\"$caddress1\",\"$caddress2\",\"$caddress3\",\"$ccity\",\"$cstate\",\"$czip\",\"$ccountry\",\"$ctel\",\"$cfax\",\"$fname\",\"$email\",\"$mtype\",\"$listing_type\",\"$category_options\")";
$result = mysql_query($sql, $connection) or die ("Could not execute database query.");
?>
Now, the
echo "<br>$category_options";
statement shows me that I have the correct data to insert. It gives me an output like:
Builder,Appliances,Appraiser,Banks,Bonding,Brokerage
But the $result statement always gives an error and I can't figure out why.
Any suggestions greatly appreciated.
Rob.