I've been going over this problem for some time and cannot find the answer. On my own server, I do not get the blank lines. On my clients server, I get two blank lines at the top for results. Here is the code:
<?
require('config.inc');
$result = mysql_query("SELECT username, user_firstname, user_middleinitial, user_lastname, user_suffix, user_occ, user_streetaddress, user_city, user_state, user_zipcode, user_homephone, user_cellphone, user_workphone, user_fax, user_email, femail, user_interests, user_status, user_level, user_password from nuke_users where user_status!=''");
$headerstuff = "username, user_firstname, user_middleinitial, user_lastname, user_suffix, user_occ, user_streetaddress, user_city, user_state, user_zipcode, user_homephone, user_cellphone, user_workphone, user_fax, user_email, femail, user_interests, user_status, user_level, user_password";
while($row = mysql_fetch_row($result))
{
$line = '';
foreach($row as $value)
{
if(!isset($value) || $value == "")
{
$value = ",";
}
else
{
$value = '"' . $value . '"' . ",";
}
$line .= $value;
}
$data .= trim($line)."\n";
}
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=users.csv");
print ($headerstuff."\n".$data);
?>
The results are 2 blank lines at the top of this file followed by the headerstuff line and then the actual data. It works, just puts 2 blank lines that I do not want at the top.
Thanks in advance for any help you can send my way!
S B