I have a chunk of code that I intend to use for comments on a website. I’m working on this in XAMPP so I don’t have a website to show you the issue live. I’ve split the code into 3 parts. The 1st part is the beginning of the script and is in a separate file included on the page in question. The 2nd part is the part that will be on every page that simply needs a file name changed for each different page. The 3rd part is the end of the script and is in a separate file and included on the page in question. So, include “code1.txt” - middle part - include “code2.txt”. The error I get says “unexpected end of file” on code1. I’d say I’m moderately experienced with PHP and have tried everything in my arsenal to fix this but alas, I cannot. I hope this is clear. Thank you!
Code1
[php]<?php
$errname = $errcomm = “”;
$name = $comment = “”;
$date = date(“F jS Y - g:i”);
if (isset($_POST[“submit”])) {
$name = $_POST[“name”];
$website = $_POST[“website”];
$comment = stripslashes(nl2br($_POST[“comment”]));
if (!empty($_POST[“website”])) { $name = “<a href=”$website" target="_blank">$name"; } else { $name = $name; }
if(!empty($_POST[“spam”])) { die(“
OMITTED you, bot!
”); } else {}if (empty($_POST[“name”])) { $errname = " error"; }
elseif (empty($_POST[“comment”])) { $errcomm = " error"; } else {[/php]
Middle
[php]<?php include "code1.txt"; ?>
$file = file(“comments/001.txt”);
$foo = fopen(“comments/001.txt”, “w+”);
fwrite ($fopen, “<div class=“comment”>\n$name ➜ $date
\n$comment\n\n\n”);
foreach ($file as $new) { fwrite($foo, “$new”); }
fclose ($foo);
header (“Location:http://localhost/mine/rh/001.php”);
Code2
[php]}
}
?>[/php]