I keep getting this error and I have tried putting quotes around the actual array, periods, nothing has worked.
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING on line 8
$id = $_GET['id'];
$record = "SELECT `Name`, `Type`, `Size`, `Content` FROM election_candidates WHERE `ID` = '$id'";
$result = $db->query($record);
foreach ($result as $results) {
header("Content-length: $results['Size']"); <---Line 8
header("Content-type: $results['Type']");
header("Content-Disposition: attachment; filename=$results['Name']");
// echo $results['Size'];
echo $results['Content'];
}
exit();
Try the complex (curly) syntax, symple syntax or the concatenation operator:
In addition you should escape
$_GET['id']and you don’t need quotes for an integer in MySQL. I’ve corrected these two “problems” in the above code.You could also add
LIMIT 1to the SQL query and remove theforeachloop 😉