PHP export to text file - Only saving first line.
Posted
by
wertz8090
on Stack Overflow
See other posts from Stack Overflow
or by wertz8090
Published on 2011-01-11T17:38:36Z
Indexed on
2011/01/11
19:54 UTC
Read the original article
Hit count: 185
I'm trying to export some extracted $_POST information into a text file, however my code is only capturing the first variable and ignoring the rest. I'm saving the information to the text file in this manner:
$values = "First Name: $fName\r\n";
$values .= "Last Name: $lName\r\n";
$values .= "Address: $address\r\n";
etc.
This is the code I use to write to the text file:
$fp = @fopen("person.data", "w") or die("Couldn't open person.data for writing!");
$numBytes = @fwrite($fp, $values) or die("Couldn't write values to file!");
@fclose($fp);
Any ideas on why it would only save the first $values ($fName) variable but not the rest of them? It actually saves the first part of the $values string for all of them (so I see Last Name:, Address:, etc. on separate lines in the text file) but the called variables $lName and $address do not appear.
© Stack Overflow or respective owner