rseigel Posted August 12, 2013 Share Posted August 12, 2013 (edited) 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 Edited August 12, 2013 by rseigel Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted August 12, 2013 Share Posted August 12, 2013 error_reporting(E_ALL); ini_set('display_errors', '1'); Quote Link to comment Share on other sites More sharing options...
rseigel Posted August 12, 2013 Author Share Posted August 12, 2013 Already have that. No errors thrown.....just a blank page. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted August 13, 2013 Share Posted August 13, 2013 code works for me (i ended up making the tables to test with after i posted the query in the previous thread.) how about echoing messages at various points to test what execution path, if any, it takes. Quote Link to comment Share on other sites More sharing options...
Solution rseigel Posted August 13, 2013 Author Solution Share Posted August 13, 2013 Ohhhhhhh yeaaaaaahhhhhh! It works. Thanks to both of you for the help. It's now exactly what I needed. Off to the next challenge....... Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted August 13, 2013 Share Posted August 13, 2013 Ohhhhhhh yeaaaaaahhhhhh! It works. Thanks to both of you for the help. It's now exactly what I needed. Off to the next challenge....... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.