I'm trying to get this code to save a csv file to the root of my hosting accont.
$result = mysql_query("SELECT p.reference AS sku, IFNULL( p.price - sp.reduction, p.price ) AS price, sa.quantity, mpo.asin1 AS 'product-id', 'ASIN' AS 'product-id-type', p.condition AS 'condition-type' FROM product p LEFT JOIN specific_price sp USING ( id_product ) JOIN stock_available sa USING ( id_product ) JOIN marketplace_product_option mpo USING ( id_product ) WHERE mpo.asin1 > ''"); if (!$result) die('Couldn\'t fetch records'); $num_fields = mysql_num_fields($result); $headers = array(); for ($i = 0; $i < $num_fields; $i++) { $headers[] = mysql_field_name($result , $i); } $csv_filename = "export-amazon.csv"; $fp = fopen($csv_filename, 'w+'); if ($fp && $result) { fputcsv($fp, $headers); while ($row = mysql_fetch_row($result)) { fputcsv($fp, array_values($row)); } }
I've been digging and digging on the internet and nothing seems to work.
In the above code, I know for a fact that the SELECT works perfectly. It just doesn't save a file.
Any ideas, thoughts, anything?? O_o
Thanks,Ron