Jump to content

[SOLVED] Cant Get PHP to write multiple lines


Grodo

Recommended Posts

I can write to one line but cant get it to do multiple of them

$csv_mailformat = file to write to

$fcsv_itemmaildata = The string that contains information to be written

$csv_mailformathandle = the pointer

I am really confused on why this wont work

Cheers,

Grodo

 

// Format Mail
$csv_mailformathandlecode]

	// Format Mail
$fcsv_itemmaildata = "\"$db_name\"\n\"$db_company\"\n\"$db_email\"\n\"$db_phone\"\n\"$db_address\"\n\"$db_address2\"\n\"$db_city\"\n\"$db_state\"\n\"$db_country\"\n\"$db_zip\"\n";
if (is_writable($csv_mailformat)) {
	if (fwrite($csv_mailformathandle, $fcsv_itemmaildata) === FALSE) {
	echo "Cannot write to file $csv_mail";
	exit; 
	}
}
fclose($csv_mailformathandle);

hmmmm that didnt work

 

However this works but only does one line

$csv_itemmaildata = "\"$db_name\",\"$db_company\",\"$db_email\",\"$db_phone\",\"$db_address\",\"$db_address2\",\"$db_city\",\"$db_state\",\"$db_country\",\"$db_zip\"\n";
if (is_writable($csv_mail)) {
	if (fwrite($csv_mailhandle, $csv_itemmaildata) === FALSE) {
	echo "Cannot write to file $csv_mail";
	exit; 
	}
}

Problem solved I Guess .csv files dont like the \n return  Changed it to a txt doc and it works like a charm. Thanks Kiss o Matic for your efforts...  Cheers

 

	$f_data = "\"$db_name\"\n\"$db_company\"\n\"$db_email\"\n\"$db_phone\"\n\"$db_address\"\n\"$db_address2\"\n\"$db_city\"\n\"$db_state\"\n\"$db_country\"\n\"$db_zip\"\n";
if (is_writable($csv_mailformat)) {
	if (fwrite($csv_mailformathandle, $f_data) === FALSE) {
	echo "Cannot write to file $csv_mail";
	exit; 
	}
}

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.