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]

Link to comment
Share on other sites

	// 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);

Link to comment
Share on other sites

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; 
	}
}

Link to comment
Share on other sites

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; 
	}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.