This question already has an answer here:
<?php
$name = $_POST['name'];
$price = $_POST['price'];
$absolute_path = "/Plants/List/index.html";
$PlantFile = fopen($_SERVER['DOCUMENT_ROOT'] . "$absolute_path", "a") or die("Unable to open file!");
$trimmedname = preg_replace('/\s+/', '', $name);
fwrite($PlantFile, "
<div class='wrapper one $trimmedname' id='main'>
<h1>$name</h1>
<p>Price: $price</p>
<?php if($_SESSION[id]) {?>
<button>Delete $name</button>
<script> var simple = \"<?php echo $trimmedname; ?>\"; $(\"button\").click(function(){$(simple).remove();}); </script>
<?php } ?>
</div>
");
fclose($PlantFile);
?>
I keep getting the error:
Parse error: syntax error, unexpected '(', expecting variable (T_VARIABLE) or '$' in your code on line 9
Could anyone help? Thanks guys!
</div>