Camyden74 Posted February 14, 2012 Share Posted February 14, 2012 I have a form that users input user name, password, and email... all writes to csv fine. My problem is I need to concatenate a a string with a variable and some html code will preserving the html when written to the csv.. I need the csv to be this username,password,email,user,category,text with http://sub.domain..com/splash/,something,something here's what i have <?php if($_POST['formSubmit'] == "Submit") $varUserName = $_POST['username']; $varPW = $_POST['PW']; $varEmail = $_POST['email']; { $fs = fopen("testcsv.csv","a"); fputcsv($fs, array($varUserName,$varPW,$varEmail,"user","title",",category","some text '<a href="http://$varUserName.url.com/splash/>site.com</a>',)); fclose($fs); exit; } ?> and of course I'm getting Parse error: syntax error, unexpected T_STRING, expecting ')' on line 9 Quote Link to comment https://forums.phpfreaks.com/topic/257097-need-to-write-html-to-csv-but-also-insert-variable-in-part-of-the-html-code/ Share on other sites More sharing options...
harristweed Posted February 16, 2012 Share Posted February 16, 2012 <?php if($_POST['formSubmit'] == "Submit") $varUserName = $_POST['username']; $varPW = $_POST['PW']; $varEmail = $_POST['email']; { $fs = fopen("testcsv.csv","a"); fputcsv($fs, array("$varUserName","$varPW","$varEmail","user","title",",category","some text '<a href=\"http://$varUserName.url.com/splash/\">site.com</a>'")); fclose($fs); exit; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/257097-need-to-write-html-to-csv-but-also-insert-variable-in-part-of-the-html-code/#findComment-1318001 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.