se il numero delle colonne che devi estrarre non è altissimo io semplificherei tutto così:

Codice PHP:
$table 'bp';
$filename 'bpfile';

$link mysql_connect($host$user$pass) or die("Can not connect." mysql_error());
mysql_select_db($db) or die("Can not connect.");

$csv_output .= "mail;telefono;fax\r\n"


$values mysql_query("SELECT mail,telefono,fax FROM ".$table."");

while (
$row mysql_fetch_array($values)) {
   
$csv_output .= $rowr['mail'].";"$rowr['telefono'].";"$rowr['fax'];
   
$csv_output .= "\r\n";
}

file_put_contents($filename.".csv",$csv_output);