I'd like to create an URL Shortener.
I have all files on my Webserver but now, when I'd like to short an url it says me:
Parse error: syntax error, unexpected end of file in /users/shrtml/www/public/submit.php on line 36
What is this? Here is my CODE:
<?php
require_once "../include/config.php";
require_once "../include/ShortUrl.php";
if ($_SERVER["REQUEST_METHOD"] != "POST" || empty($_POST["url"])) {
header("Location: shorten.html");
exit;
}
try {
$pdo = new PDO(DB_PDODRIVER . ":host=" . DB_HOST . ";dbname=" . DB_DATABASE,
DB_USERNAME, DB_PASSWORD);
}
catch (\PDOException $e) {
header("Location: error.html");
exit;
}
$shortUrl = new ShortUrl($pdo);
try {
$code = $shortUrl->urlToShortCode($_POST["url"]);
}
catch (\Exception $e) {
header("Location: error.html");
exit;
}
$url = SHORTURL_PREFIX . $code;
echo <<<ENDHTML
<html>
<head>
<title>URL Shortener</title>
</head>
<body>
<p><strong>Short URL:</strong> <a href="$url">$url</a></p>
</body>
</html>
ENDHTML; <<< This is line 34. End of file.