fputcsv is a PHP function that formats a line (passed as a fields array) as CSV and writes it (terminated by a newline) to the specified file handle. `fputcsv` support started with PHP version 5.1.0.
Questions tagged [fputcsv]
354 questions
0
votes
1 answer
fputcsv returns double values
So currently i'm trying to make a database exporting script, what I got is this:

Azrael
- 1,094
- 8
- 19
0
votes
2 answers
How To Skip Some Fields From Database While Using fputcsv
I am Using Following code For getting csv file of mysql database. But I want to skip some fields in database while getting it in csv format.
e.g. Fields In databse are id, firstname, last name, username, password, email, membership date, last login…

darshan
- 319
- 3
- 16
0
votes
2 answers
SQL to PHP to CSV most efficient method
I just want to double check the most efficient method of writing to a CSV file with PHP using data retrieved from a database.
Currently after executing my sql query to retrieve the data I am using a while loop to assign the data to varaibles, then…

Shamrockonov
- 489
- 2
- 7
- 19
0
votes
1 answer
format fputcsv with header row and each column etc currently all inserting to first column
I'm having a hard time trying to figure out how to properly format these fputcsv lines.
Here is the code I am using to write my query to a csv file.
$handle = fopen( $dir .'/export.csv', 'w');
$headers = 'Category Name, ID';
…

Bowenac
- 493
- 8
- 19
0
votes
2 answers
fputcsv - Function gives Error.
I'm trying to export my data into a csv file and let the user to download it. I'm using fputcsv() function, but in the file, the data are written in a single cell instead of adjacent cells. I don't know what is the problem. Please help me. here is…

Vignesh
- 1,045
- 2
- 17
- 34
0
votes
2 answers
euro sign from php to csv shows Â
I´m having trouble with the output to a csv file with the euro sign. i´ve tried using € which doesn´t work and the &euro which also doesn´t work. This only works in my table view but not when exported to csv.
Hopes someone could help me…

Graham
- 1,850
- 4
- 21
- 41
0
votes
2 answers
putcsv formatting wrong when result is from pdo
I am trying to import data from a db via pdo and output the results to a csv file. I am able to output to a screen correctly but the formatting in the csv is wild, double names and no '\n'

brad
- 870
- 2
- 13
- 38
0
votes
1 answer
append new data to existing csv php
I'm using the code below for adding data into a csv file based on a import from a csv file. When I write the new data to a new csv file everything looks ok! But I would like to append the new data into new columns. I will try to explain with a…

user3414694
- 7
- 1
- 6
0
votes
1 answer
Want to save array values in CSV file into two columns. Currently all values are in one row
I am storing one CSV file values into another through PHP.
I want to save $col_1_values_array values in one column into CSV file and $col_2_values_array into another column. although my code is showing all values into a single row,how can i correct…

user3140387
- 9
- 4
0
votes
0 answers
fputcsv works on local machine but not on server
I'm having an issue where the following php script works as expected and writes the following array data to a csv file on my local machine, but when I upload this script to the server the csv file (located on the server) isn't written to when…

12th
- 11
- 3
0
votes
1 answer
The csv file created not properly
SO i have been trying to create a simple csv file as code below but the csv file not created properly. It contained the html text that are in my .php file.

yuli
- 1
- 3
0
votes
0 answers
PHP fputcsv via XPath enclosure issue
I fetch a lot of xml data and parse this via XPath.
When writing the data to a file, I always get the enclosure tag in a wrong position additionally to the first enclosure.
Here is the code:
// define xpath expressions for the columns [] in v5.4+
…

Sebastian Rush
- 528
- 6
- 25
0
votes
1 answer
PHP Create csv from database. The database isn't saved but it adds the htmlcode of the current page at the end of file
This Code works fine:
$csvType = $_FILES['csvtype']['tmp_name']['csv-sparkasse'];
function handleCsv($em, $csvType){
$handle = fopen($csvType, "r");
$i = 0;
while (($fileop = fgetcsv($handle, 1000, ";")) !== false) {
…

chuebert
- 136
- 1
- 6
0
votes
1 answer
PHP fputcsv to .xls with style
I am trying to export some data to an excel sheet using fputcsv on PHP. I know that .csv files do not support style. If there any way I can add style to that file by saving the file as .xls?

Harris Geo
- 239
- 2
- 4
- 14
0
votes
3 answers
Is it possible to define column\cell format in CSV file?
In my project I generate a CSV file for the user to download. In one of the columns there are values that can start with 0.
However when the user downloads the file and opens it the zeros disappear.

user1908466
- 503
- 1
- 8
- 17