0

Hi, complete newbie and having a syntax error:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in xxx on line 7

This is line 7:

fputs($fp, "$_POST['Fullname'],$_POST['Jobtitle'],$_POST['email'],$_POST['file'],\n");

Like i say im a complete newbie to this and from what i gather brackets might be missing etcetc. This was cut and pasted from some other code i found on this site but unfortunately dont have the link to hand.
Please advise, its driving me nuts.
Cheers
Jocky

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by jocky c
0

This will probably fix it:

fputs($fp, "{$_POST['Fullname']},{$_POST['Jobtitle']},{$_POST['email']},{$_POST['file']},\n");
0
fputs($fp, "{$_POST['Fullname']},{$_POST['Jobtitle']}, {$_POST['email']} ,{$_POST['file']} ,\n");

Use braces {} to encapsulate variables in string

0

Wow thanks guys for the immediate response yep that sorted it but highlighted other errors namely in these 2 lines:

.'<input name="file" type="hidden" value="'.$file.'">';
.'Fullname ?<input name="Fullname" type="text"><br>';

The complte code is here:

<?php /*download.php*/
If (!$_POST['file']='') {
/* validate $_POST  any amount of form validation this is just an exercise
or die('invalid information'); */
$file = "./logfiles/logfile.csv";// define the text file, named as .csv excell can open it.
$fp = fopen($file, "a+");//open the text file for writing.
fputs($fp, "{$_POST['Fullname']},{$_POST['Jobtitle']},{$_POST['email']},{$_POST['file']},\n");
fclose($fp);
$path=''; //full path outside the root to downloadable files
header("Content-disposition: attachment; filename={$_POST['file']}");
header('Content-type: application/pdf;');
readfile("$path{$_POST['file']}"); }
else {echo '<form action="'.$_SERVER['php_self'].'" method="post">';
.'<input name="file" type="hidden" value="'.$file.'">';
.'Fullname ?<input name="Fullname" type="text"><br>';
.'Jobtitle ?<input name="Jobtitle" type="text"><br>';
.'email ?<input name="email" type="text"><br>';
.'<input name="go" type="submit" Value="Download file"></form>'; }
?>

Any advise is greatly appreciated.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.