2016-01-13 124 views
0

我有一個網站,在我的本地主機上使用xampp完美工作,但是......我將它上傳到幾個免費網站託管(000webhost和hostinger),當我嘗試打開它時,得到此消息:PHP致命錯誤:require()

Warning: require(core/libs/smarty/Smarty.class.php): failed to open stream: No such file or directory in /home/u327900732/public_html/www/index.php on line 7

Fatal error: require(): Failed opening required 'core/libs/smarty/Smarty.class.php' (include_path='.:/opt/php-5.5/pear') in /home/u327900732/public_html/www/index.php on line 7

這是代碼:

<?php 

session_start(); 

$view = isset($_GET['view']) ? $_GET['view'] : 'index'; 

require_once('core/libs/smarty/Smarty.class.php'); 
require('core/models/class.Conexion.php'); 

if(file_exists('core/controllers/'.$view.'Controller.php')){ 
    include('core/controllers/'.$view.'Controller.php'); 
}else { 
    include('core/controllers/errorcontroller.php'); 
} 

?> 

我檢查了文件一個百倍,它是存在的。

我發現並試用了此解決方案:

  • 更改需要包括:

Warning: include(core/libs/smarty/Smarty.class.php): failed to open stream: No such file or directory in /home/u327900732/public_html/www/index.php on line 7

Warning: include(): Failed opening 'core/libs/smarty/Smarty.class.php' for inclusion (include_path='.:/opt/php-5.5/pear') in /home/u327900732/public_html/www/index.php on line 7

Fatal error: Class 'Smarty' not found in /home/u327900732/public_html/www/core/controllers/indexController.php on line 3

  • 要求(CHDIR(目錄名(FILE))的核心/庫/ smarty的/ Smarty.class.php');

Warning: require(1core/libs/smarty/Smarty.class.php): failed to open stream: No such file or directory in /home/u327900732/public_html/www/index.php on line 7

Fatal error: require(): Failed opening required '1core/libs/smarty/Smarty.class.php' (include_path='.:/opt/php-5.5/pear') in /home/u327900732/public_html/www/index.php on line 7

  • 更改線7
    require_once($ _ SERVER [ 'DOCUMENT_ROOT'] '/核心/庫/ smarty的/ Smarty.class.php');

Warning: require_once(/home/u327900732/public_html/core/libs/smarty/Smarty.class.php): failed to open stream: No such file or directory in /home/u327900732/public_html/www/index.php on line 7

Fatal error: require_once(): Failed opening required '/home/u327900732/public_html/core/libs/smarty/Smarty.class.php' (include_path='.:/opt/php-5.5/pear') in /home/u327900732/public_html/www/index.php on line 7

我嘗試添加「./」的路徑,但它仍然無法正常工作。我再說一遍,該網站在我的本地主機上完美運行。請幫助!

+0

服務器上是否需要(Smarty)文件? – user2182349

+0

如果該文件實際上位於服務器上,那麼您可能需要通過其位於服務器上的核心路徑進行訪問。像'require_once($ _ SERVER ['DOCUMENT_ROOT']。'/ core/libs/smarty/Smarty.class.php');'會工作。你可能需要根據你的目錄設計來調整它。 – camelCase

+0

@ user2182349 Smarty文件位於我的主文件夾中,並且我將完整的主文件夾上載到服務器。 – user3891850

回答

0

試圖使用完整的網址來測試你的網址。或者檢查您的瀏覽器以檢查文件是否存在。喜歡這裏:

http://host.com/core/libs/smarty/Smarty.class.php

我認爲它會顯示錯誤,顯示你的文件是不存在的存在。