Jump to content

Need to write html to csv but also insert variable in part of the html code


Camyden74

Recommended Posts

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

Link to comment
Share on other sites

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

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.