fputcsv function - nothing happens

I am working on a new plugin and one of the features it suppose to have is to put some data in a .csv file. When using the fputcsv function, nothing happens. I am not getting any errors but the data is not inserted into the file.

This is the code:

$file_name = date( ‘Y’ ).’_’.date( ‘m’ ).’_’.date( ‘d’ ).’.csv’;
$file_path = plugins_url( ‘packages_tables/’.$file_name, __FILE__ );

if ( file_exists( $file_path ) ) {
$order->add_order_note( ‘File exists’ );
} else {
$columns_headers = Array(‘test1’, ‘test2’, ‘test3’);
$put_csv = fopen($pegasus_file_path, ‘a+’);
fputcsv($put_csv , $columns_headers);
$order->add_order_note( ‘Error!’ );
}

I also tried to change file permissions but did not help…

Thanks!

Read more here:: fputcsv function - nothing happens

Leave a Reply

Your email address will not be published. Required fields are marked *