PHP export to text file - Only saving first line.
- by wertz8090
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.