2012-12-07 136 views
-1

Possible Duplicate:
failed to open stream: Invalid argumentrequire_once();無效的參數錯誤

// Define the core paths 
// Define them as absolute paths to make sure that require_once works as expected 

// DIRECTORY_SEPARATOR is a PHP pre-defined constant 
// (\ for Windows,/for Unix) 
defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); 

defined('SITE_ROOT') ? null : 

define('SITE_ROOT', DS.'C:'.DS.'wamp'.DS.'www'.DS.'photo_gallery'); 

defined('LIB_PATH') ? null : define('LIB_PATH', SITE_ROOT.DS.'includes'); 

// load config file first 
require_once(LIB_PATH.DS.'config.php'); 

// load basic functions next so that everything after can use them 
require_once(LIB_PATH.DS.'functions.php'); 

// load core objects 
require_once(LIB_PATH.DS.'session.php'); 
require_once(LIB_PATH.DS.'database.php'); 

// load database-related classes 
require_once(LIB_PATH.DS.'user.php'); 

無論何時,我想在我的地址欄本地主機/ photo_gallery /公/管理/ index.php文件輸入到運行該代碼。它會顯示如下錯誤:

Warning: require_once(\C:\wamp\www\photo_gallery\includes\config.php): failed to openstream: Invalid argument in C:\wamp\www\photo_gallery\includes \initialize.php on line 16.

Fatal error: require_once(): Failed opening required '\C: \wamp\www\photo_gallery\includes\config.php'(include_path='.;C:\php\pear') in C:\wamp\www\photo_gallery\includes\initialize.php on line 16

請告訴我該怎麼辦?是一個初學者啓動webdesigner,並陷入這個致命的錯誤。

+0

使用定義,而不是定義 – Hkachhia

+0

這麼多的重複:http://stackoverflow.com/questions/13759360/fatal-error-require-once-failed-opeining-required-c-wamp-www-photo-畫廊,http://stackoverflow.com/questions/13759794/require-once-failed-to-openstream-invalid-argument-in-c-wamp-www-photo-gall#13759794 –

+0

你給的答案解釋你的錯誤完美。我們不提供勺子,錯誤在於該文件不存在。現在處理它,不過你想。 –

回答

0

DS是在下面的行額外:

定義( 'SITE_ROOT',DS.'C: 'DS.'wamp'.DS.'www'.DS.'photo_gallery');

請刪除它,所以它成爲

define('SITE_ROOT', 'C:'.DS.'wamp'.DS.'www'.DS.'photo_gallery'); 

使用定義,而不是定義

0

試試這個。

<?php 

    defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); 

    define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT']); 

    define('LIB_PATH', SITE_ROOT.DS.'includes'); 

    require_once(LIB_PATH.DS.'config.php'); 
    // load basic functions next so that everything after can use them 
    require_once(LIB_PATH.DS.'functions.php'); 

    // load core objects 
    require_once(LIB_PATH.DS.'session.php'); 
    require_once(LIB_PATH.DS.'database.php'); 

    // load database-related classes 
    require_once(LIB_PATH.DS.'user.php'); 

?> 
+0

不過,它沒有改變。它仍然繼續相同的錯誤結果。 – user1884440

+0

1)不要使用絕對和硬編碼的路徑,這不是一個好習慣。 2)使用SERVER變量獲得dyanamic路徑,而不管相對或絕對不管。 3)最後在php.ini中檢查你的路徑,你可以在phpinfo中檢查它並讓我知道這裏的路徑。 嘗試使用require_once(「../ config.php」)等相對路徑包含單個文件;並檢查它是否工作。 –

+0

檢查我最新的編輯過的代碼並嘗試它。 –