I am trying to pull data from SQL, and then write it to a text file. This does that, to an extent, but it only pulls 1 from the table, which reads test:test<
It looks like you are reopening and rewriting the entire contents of the file with every pass through your while loop.
Try this:
";
fwrite($fh, $accounts);
}
fclose($fh);
echo "TEST!";
?>
Also, if you don't want the < br >, but a real line break, use:
$accounts = "$user:$pass\n";