You should put your whole query code in the foreach then:
foreach($orderClass->products as $product){
$ok = false; //Product ID check
if($product->product_id == 1 || $product->product_id == 18 || $product->product_id == 42 || $product->product_id == 46 || $product->product_id == 22 || $product->product_id == 23 || $product->product_id == 43 || $product->product_id == 47) $ok = true;
if($ok){
$qty = $product->order_product_quantity;
$notes .= " Quantity: ";
$notes .= "$qty";
$PID = $product->product_id;
$notes .= " PID: ";
$notes .= "$PID";
for ($i=1; $i<=$qty; $i++)
{
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_set_charset('utf8',$con);
mysql_select_db("test", $con);
mysql_query("INSERT INTO contacts2 (`First Name`, `Last Name`, `E-mail Address`, `Home Phone`, Address, City, `State/Province`, `Post Code`, `Country/Region`, `Date Subscribed`, `Subscription End Date`, `Notes`)
VALUES ('$fname', '$lname', '$email', '$tel', '$add', '$city', '$state', '$pcode', '$country', NOW(), DATE_ADD(NOW(), INTERVAL 1 YEAR), '$notes')");
mysql_close($con);
} // end of for loop
} // end of if OK
}