the code is supposed to insert multiple rows and once it's completed it will redirect to another page. Well it redirects but not insert. Here is code.
//remove backlashes
nukeMagicQuotes();
//create database connection
$conn = new mysqli('localhost', $user, $pwd, 'mosquito') or die ('Cannot open database');
// data that stays static
$trap = $_POST['TRAP'];
$day = $_POST['DAY'];
$week = $_POST['WEEK'];
$local = $_POST['LOCAL'];
$date = ('NOW()');
$same = array("$trap", "$day", "$week", "$local", "$date");
//grouping first data group
$s1 = $_POST['SPECIES1'];
$m1 = $_POST['MALE1'];
$f1 = $_POST['FMALE1'];
$group[] = array("$s1", "$m1", "$f1");
//grouping second data group
$s2 = $_POST['SPECIES2'];
$m2 = $_POST['MALE2'];
$f2 = $_POST['FMALE2'];
$group[] = array("$s2", "$m2", "$f2");
//arrainging data into rows
foreach ($group as $row) {
$row[]= array(array_merge($group, $same));
}
//preparing data of insert into table
$query_values = implode(',', $row);
$query = "INSERT INTO collections (SPECIES, MALE, FMALE, TRAP, DAY, WEEK, LOCAL, DATE) VALUES $query_values";
$result = mysql_query($query, $conn);
//redirect if successful or disply error
if (!result) {
die ('Error: '.mysql_error());
}
else {
header('Location: mosMain.php');
}