0){ $q_insert = "INSERT INTO Daily_Report (sku, last4weeks, last2weeks, lastweek, highest, `afn-fulfillable-quantity`, `afn-reserved-quantity`, `afn-inbound-working-quantity`, `afn-inbound-shipped-quantity`, `afn-inbound-receiving-quantity`, `outbound` ) VALUES ('{$row['sku']}', '{$row4week['SUM(quantity)']}', '{$row2week['SUM(quantity)']}', '{$row1week['SUM(quantity)']}', '$highest', '{$row['afn-fulfillable-quantity']}', '{$row['afn-reserved-quantity']}', '{$row['afn-inbound-working-quantity']}', '{$row['afn-inbound-shipped-quantity']}', '{$row['afn-inbound-receiving-quantity']}', '$outbound' )"; $r_insert = @mysqli_query ($dbc, $q_insert); // Run the query. if (!$r_insert) { $results[] = "*******ERROR********COULD NOT INSERT INTO DAILY REPORTS" . mysqli_error($dbc) . ' ' . $q2_fix_dates; // Debugging message: } } } //Close the database connection. mysqli_close($dbc); //Outputs messages to a browser if run manually echo "
"; print_r($results); echo "
";
//Send an email confirmation with all results each time it runs:
$to = "grace@gmrbowden.com";
$subject = "Nightly Amazon Import";
$headers = "From: imports@customer-site";
$msg = "Results: " . print_r($results, true); 
mail($to,$subject,$msg,$headers);
?>