0

我正在制作我的第一个网站,其中涉及一些 PHP,每次按下前一页上的操作按钮时都会出现错误。这是错误的文本:

警告:require_once(./include/config.php) [function.require-once]:无法打开流:/var/www/u5161155/data/www/sh0rt.ru/submit.php 中没有这样的文件或目录2号线

致命错误:require_once() [function.require]:在 /var/www/u5161155/data/www/sh0rt.ru/submit 中打开所需的 './include/config.php' (include_path='.:') 失败。第 2 行的 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;

我理解一个错误,但我不明白为什么它没有打开它。我在正确的目录中得到了正确的文件。这就是我寻求帮助的原因

4

1 回答 1

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";
于 2013-02-11T20:38:30.460 回答