我正在制作我的第一个涉及PHP的网站,每次按下上一页的操作按钮时都会收到错误。这是一个错误的文本:
警告:require_once(./ include / config.php)[function.require-once]:无法打开流:/var/www/u5161155/data/www/sh0rt.ru/submit中没有此类文件或目录第2行的.php
致命错误:require_once()[function.require]:在/var/www/u5161155/data/www/sh0rt.ru中打开所需的'./include/config.php'(include_path =':')失败第2行的/submit.php
这是我的代码
<?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;
我理解错误,但我无法理解它为什么不打开它。我在正确的目录中找到了正确的文件。这就是我要求帮助的原因
答案 0 :(得分:0)
尝试更改第一行:
require_once "./include/config.php";
require_once "./include/ShortUrl.php";
到
require_once "/var/www/u5161155/data/www/sh0rt.ru/include/config.php";
require_once "/var/www/u5161155/data/www/sh0rt.ru/include/ShortUrl.php";