0

I'm making my first website with some PHP involved and I'm getting an error every time I press an action button on a previous page. This is a text of an error:

Warning: require_once(./include/config.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/u5161155/data/www/sh0rt.ru/submit.php on line 2

Fatal error: require_once() [function.require]: Failed opening required './include/config.php' (include_path='.:') in /var/www/u5161155/data/www/sh0rt.ru/submit.php on line 2

This 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;

I understand an error, but I can't get why it doesn't open it. I got the right file in the right directory. That's why I'm asking for help

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 に答える