Jump to content

Mysql backup CSV


yogibear

Recommended Posts

Hi I have been trying to backup one of my tables using this code and it works however when i tried restoring the table using phpmyadmin i got an error on line 1. i believe the problem is lines terminated is ; and so is fields terminated when i export using phpmyadmin i can set what i what them to be how can i change lines terminated in the code to be : rather than ; without changing field terminated.

 

$out = ''; 

// Get all fields names in table "name_list" in database "tutorial".
$fields = mysql_list_fields($database,$table);

// Count the table fields and put the value into $columns. 
$columns = mysql_num_fields($fields);

// Add all values in the table to $out. 
while ($l = mysql_fetch_array($result)) {
for ($i = 0; $i < $columns; $i++) {
$out .='"'.$l["$i"].'";';
}
$out .="\n";
}

 

this is the export uing phpmyadmin

"test";"test";"test";"test";"test";"test";"test";"2007-10-07";"2007-11-07";"0";"0";"2007-12-09";"0";"testt";"t";"test":

this is the export using the code on my website

"test";"test";"test";"test";"test";"test";"test";"2007-10-07";"2007-11-07";"0";"0";"2007-12-09";"0";"testt";"t";"test";

Link to comment
https://forums.phpfreaks.com/topic/60056-mysql-backup-csv/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.