$result = mysql_query("SELECT * FROM table");
while($row = mysql_fetch_array($result)) {
$append = "\"INSERT INTO table VALUES(".$row[field1'].","
.$row['field2'].",".$row['field3'].")\";";
$fp = fopen("$filename", "a") or die("Couldn't open $filename");
fputs($fp, $append."\n");
fclose($fp);
}
This is my script. It runs ok until field $row['field2']. Then it leaves some blank lines after some rows of file and not others. After that it will insert a new line before the comma on some lines and not others.
The final result is scattered lines with new lines starting in different places of row.