alanl1 Posted July 22, 2013 Share Posted July 22, 2013 Hi All I have been writing my DB values to a csv without any problems until now. When I extract a date field it does not write to the file. Please find below the code that works and the code that does not work working while($row = sqlsrv_fetch_array($exportquery1)) { fputcsv($handle, array($row['businessunit'],$row['costcentre'])); } // Finish writing the file fclose($handle); not working while($row = sqlsrv_fetch_array($exportquery1)) { fputcsv($handle, array($row['businessunit'],$row['costcentre'],$row['Tdate])); } // Finish writing the file fclose($handle); any ideas what I would need to do, when I query within the backend database it is fine Quote Link to comment https://forums.phpfreaks.com/topic/280405-another-issue-i-cant-figure-with-fputcsv/ Share on other sites More sharing options...
requinix Posted July 23, 2013 Share Posted July 23, 2013 Is your code missing a quote or did you not copy/paste your code here? Quote Link to comment https://forums.phpfreaks.com/topic/280405-another-issue-i-cant-figure-with-fputcsv/#findComment-1441725 Share on other sites More sharing options...
alanl1 Posted July 23, 2013 Author Share Posted July 23, 2013 sorry yes that code should be there that is just a copy and past error when I was showing example. it should be fputcsv($handle, array($row['businessunit'],$row['costcentre'],$row['Tdate'])); do you think it could be something to do with the quotes with the dat conversion? regards Quote Link to comment https://forums.phpfreaks.com/topic/280405-another-issue-i-cant-figure-with-fputcsv/#findComment-1441727 Share on other sites More sharing options...
mac_gyver Posted July 23, 2013 Share Posted July 23, 2013 is that the exact spelling and capitalization of your database column name? are you selecting that column in your query statement? do you have php's error_reporting set to E_ALL and display_errors set to ON so that php will help you by reporting and displaying the errors it detects? Quote Link to comment https://forums.phpfreaks.com/topic/280405-another-issue-i-cant-figure-with-fputcsv/#findComment-1441729 Share on other sites More sharing options...
Solution alanl1 Posted July 23, 2013 Author Solution Share Posted July 23, 2013 I have managed to get this to display by doing amending the column in the DB to date and also changing the query to CONVERT(varchar, DATEPART(dd, Tdate)) + '/' + CONVERT(varchar, DATEPART(mm, Tdate)) + '/' + CONVERT(varchar, DATEPART(yyyy, Tdate)) as Tdate just one question, how do i actually set error_reporting set to E_ALL and display_errors set to ON so that php will help me in displaying the errors it detects? Quote Link to comment https://forums.phpfreaks.com/topic/280405-another-issue-i-cant-figure-with-fputcsv/#findComment-1441737 Share on other sites More sharing options...
.josh Posted July 23, 2013 Share Posted July 23, 2013 error_reporting(E_ALL); ini_set('display_errors', '1'); Quote Link to comment https://forums.phpfreaks.com/topic/280405-another-issue-i-cant-figure-with-fputcsv/#findComment-1441789 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.