I am using PHP script to generate CSV file. For some reason when the script creates the CSV file it adds a quote - " - at the end of the first variable on the first column of the CSV file. I went line by line to see if I had an extra quote but could not fine any typos. Can some one help me if I am over looking at the script?
Code: Select all
<?
$header = "header.html";
$footer = "footer.html";
$returnpage = "/";
$youremail = "arashidi@implantdirect.com";
$csvfilename = "FDA/FDA.csv";
$csvquote = "\"\"";
$mode = "BOTH";
//##############################################################
//#FUNCTION: doFormError #
//#RETURNS: #
//#PARAMETERS: A error message string. #
//#PURPOSE: Generates an HTML page indicating a form #
//# submission error occurred. #
//##############################################################
function doFormError($errString) {
include($header);
echo "<FONT SIZE=+2>The form you submitted was not complete.<BR><BR></FONT>";
echo "$errString<BR><BR>\n";
echo "<INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE=' Return to the form '><HR>";
include($footer);
exit;
}
//##############################################################
//#FUNCTION: doError #
//#RETURNS: #
//#PARAMETERS: A error message string. #
//#PURPOSE: Generates an HTML page indicating an error #
//# occurred. #
//##############################################################
function doError($errString) {
include($header);
echo "$errString<BR><BR>\n";
include($footer);
exit;
}
//##############################################################
//##############################################################
//### MAIN ###
//##############################################################
//##############################################################
if (($myfirst == "") || ($lName == "") || ($email == "") || ($pNumber1 == "") || ($pNumber2 == "") || ($pNumber3 == "")) {
doFormError("I'm sorry, but it appears that you have forgotten to fill the required field(s). Please go <A HREF='Javascript:history.go(-1);'>back</A> and correct the error(s).");
exit;
}
//# checks for valid email address
if( !(ereg("^(.+)@(.+)\\.(.+)$",$email)) ) {
doFormError("I am sorry, You have submitted an invalid e-mail address. In order to get a confirmation e-mail you must provide a valid e-mail address.
Please go <A HREF='Javascript:history.go(-1);'>back</A> and correct the error.");
exit;
}
$today = date ("l, F jS Y");
$strMessageBody = "";
$strMessageBody .= "\n";
$strMessageBody .= "Date: $today \n";
$strMessageBody .= " \n";
$strMessageBody .= "Here is the information you have submitted: \n";
$strMessageBody .= "-------- \n";
$strMessageBody .= "A. Originator Information: \n";
$strMessageBody .= " 1. First Name: \t $myfirst \n";
$strMessageBody .= " 2. Last Name: \t $lName \n";
$strMessageBody .= " 3. Title/Organization: $title \n";
$strMessageBody .= " 4. E-Mail Address: \t $email \n";
$strMessageBody .= " 5. Phone Number: \t ($pNumber1) $pNumber2 - $pNumber3 \n";
$strMessageBody .= " 6. Fax Number: \t ($fNumber1) $fNumber2 - $fNumber3 \n";
$strMessageBody .= " 7. Street Address: \t $sAddress \n";
$strMessageBody .= " 8. City: \t $city \n";
$strMessageBody .= " 9. State/Province: \t $state \n";
$strMessageBody .= " 10. Postal Code: \t $zipCode \n";
$strMessageBody .= " 11. Country: \t $country \n";
$strMessageBody .= "\n";
$strMessageBody .= "B. Patient Information: \n";
$strMessageBody .= " 1. Date of Birth: \t $date1 \n";
$strMessageBody .= " 2. Sex: \t $sex \n";
$strMessageBody .= " 3. Weight: \t $weight $weightUnit \n";
$strMessageBody .= "\n";
$strMessageBody .= "C. Product Report: \n";
$strMessageBody .= " 1. $clinic $product \n";
$strMessageBody .= " 2. Date of Event: \t $date2 \n";
$strMessageBody .= " 3. Describe Event or Problem: \t $C3 \n";
$strMessageBody .= " 4. Other relevant information to consider, including other preexisting conditions: $OtherRelevantHistory \n";
$strMessageBody .= " 5. Other Relevant Information to consider, Including Preexisting Conditions: \n";
$strMessageBody .= "\n";
$strMessageBody .= "D. Product Information: \n";
$strMessageBody .= " 1. Device Name: \t $maker \n";
$strMessageBody .= " 1.1 Device Type: \t $typer \n";
$strMessageBody .= " 1.2 Device Model: \t $modelr \n";
$strMessageBody .= " 1.3 Lot Number: \t $lotNumber1 \n";
$strMessageBody .= "\n";
$strMessageBody .= " 2. Device Name: \t $makerr \n";
$strMessageBody .= " 2.1 Device Type: \t $typerr \n";
$strMessageBody .= " 2.2 Device Model: \t $modelrr \n";
$strMessageBody .= " 2.3 Lot Number: \t $lotNumber2 \n";
$strMessageBody .= "\n";
$strMessageBody .= " 3. Device Name: \t $makerrr \n";
$strMessageBody .= " 3.1 Device Type: \t $typerrr \n";
$strMessageBody .= " 3.2 Device Model: \t $modelrrr \n";
$strMessageBody .= " 3.3 Lot Number: \t $lotNumber3 \n";
$strMessageBody .= "\n";
$strMessageBody .= " 4. Device Available for Evaluation: $available \n";
$strMessageBody .= " 5. If Implanted, Give Date: $date3 \n";
$strMessageBody .= " 6. If Explanted, Give Date: $date4 \n";
$strMessageBody .= " 7. Please list additional devices as necessary: $additionalInfo \n";
$strMessageBody .= "\n";
$strMessageBody .= "E. Upload Files: \n";
$strMessageBody .= " 1. File Name(s): \t $Upload";
//if( $NAME_2 ) {$strMessageBody .= "$QUANTITY_2 \$$PRICE_2 $ID_2 - $NAME_2 $ADDTLINFO_2 \n";}
if( $mode == "BOTH" || $mode == "EMAIL") {
//# Send email order to Ahmad Rashidi...
$mailheaders = "From: $email\r\n";
$subject = "Customer Complaint / Feed Back Form";
mail($youremail, $subject, $strMessageBody, $mailheaders);
}
if( $mode == "BOTH" || $mode == "FILE") {
//$csvcomments = $comment;
if (!$CSVF = fopen($csvfilename,'a')) {
doError("Unable to connect to the database. Your information has not been saved to our datebase!");
exit;
}
//fputs($CSVF, $string);
//fputs($CSVF, "\",\"");
fputs($CSVF, "$myfirst");
fputs($CSVF, "\",\"");
fputs($CSVF, "$lName");
fputs($CSVF, "\",\"");
fputs($CSVF, "$title");
fputs($CSVF, "\",\"");
fputs($CSVF, "$email");
fputs($CSVF, "\",\"");
fputs($CSVF, "$pNumber1-$pNumber2-$pNumber3");
fputs($CSVF, "\",\"");
fputs($CSVF, "$fNumber1-$fNumber2-$fNumber3");
fputs($CSVF, "\",\"");
fputs($CSVF, "$sAddress");
fputs($CSVF, "\",\"");
fputs($CSVF, "$city");
fputs($CSVF, "\",\"");
fputs($CSVF, "$state");
fputs($CSVF, "\",\"");
fputs($CSVF, "$zipCode");
fputs($CSVF, "\",\"");
fputs($CSVF, "$country");
fputs($CSVF, "\",\"");
fputs($CSVF, "$date1");
fputs($CSVF, "\",\"");
fputs($CSVF, "$sex");
fputs($CSVF, "\",\"");
fputs($CSVF, "$weight");
fputs($CSVF, "\",\"");
fputs($CSVF, "$weightUnit");
fputs($CSVF, "\",\"");
fputs($CSVF, "$clinic");
fputs($CSVF, "\",\"");
fputs($CSVF, "$product");
fputs($CSVF, "\",\"");
fputs($CSVF, "$date2");
fputs($CSVF, "\",\"");
fputs($CSVF, "$C3");
fputs($CSVF, "\",\"");
fputs($CSVF, "$C4");
fputs($CSVF, "\",\"");
fputs($CSVF, "$C5");
fputs($CSVF, "\",\"");
fputs($CSVF, "$maker");
fputs($CSVF, "\",\"");
fputs($CSVF, "$typer");
fputs($CSVF, "\",\"");
fputs($CSVF, "$modelr");
fputs($CSVF, "\",\"");
fputs($CSVF, "$lotNumber1");
fputs($CSVF, "\",\"");
fputs($CSVF, "$makerr");
fputs($CSVF, "\",\"");
fputs($CSVF, "$typerr");
fputs($CSVF, "\",\"");
fputs($CSVF, "$modelrr");
fputs($CSVF, "\",\"");
fputs($CSVF, "$lotNumber2");
fputs($CSVF, "\",\"");
fputs($CSVF, "$makerrr");
fputs($CSVF, "\",\"");
fputs($CSVF, "$typerrr");
fputs($CSVF, "\",\"");
fputs($CSVF, "$modelrrr");
fputs($CSVF, "\",\"");
fputs($CSVF, "$lotNumber3");
fputs($CSVF, "\",\"");
fputs($CSVF, "$available");
fputs($CSVF, "\",\"");
fputs($CSVF, "$date3");
fputs($CSVF, "\",\"");
fputs($CSVF, "$date4");
fputs($CSVF, "\",\"");
fputs($CSVF, "$additionalInfo");
fputs($CSVF, "\",\"");
fputs($CSVF, "$datefield");
//Sameer's balnk fields:
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0001");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0002");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0003");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0004");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0005");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0006");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0007");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0008");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0009");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0010");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0011");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0012");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0013");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0014");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0015");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0016");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0017");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0018");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0019");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0020");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0021");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0022");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0023");
fputs($CSVF, "\",\"");
fputs($CSVF, "$blank_0024");
//end of the blank fields
fputs($CSVF, "\"\n");
fclose($CSVF);
}
//# Send email conformation to the customer.....
$mailheaders = "From: $youremail\r\n";
$subject = "Implant Direct LLC";
mail($email, $subject, $strMessageBody, $mailheaders);
include($header);
echo "<h2>Customer Complain / Feed Back Form</h2>";
echo "Thank you for contacting Implant Direct LLC. You will receive a confirmation e-mail from us ";
echo "momentarily. Please contact us at <a href=\"mailto:arashidi@implantdirect.com\">XXXX</a> if you have any questions or concerns.";
echo "<P>";
//echo "<A HREF=\"$returnpage\" target=_top>Return Home</A>";
echo "<P>";
include($footer);
?>