Matt_M Posted March 5, 2008 Share Posted March 5, 2008 When I try to load my site, I get this error: Warning: require_once(/php/Constants.php) [function.require-once]: failed to open stream: No such file or directory in /home/fhlinux201/c/carsearchuk.co.uk/user/htdocs/index.php on line 2 Fatal error: require_once() [function.require]: Failed opening required '/php/Constants.php' (include_path='.:/usr/share/pear/') in /home/fhlinux201/c/carsearchuk.co.uk/user/htdocs/index.php on line 2 Can anyone please offer some advice or solution to why this is appearing. Any help will be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 5, 2008 Share Posted March 5, 2008 use the include("folder/page.php"); function.......... looks like to me you havent set the folder permissions to 777 or 0777 Quote Link to comment Share on other sites More sharing options...
Matt_M Posted March 5, 2008 Author Share Posted March 5, 2008 use the include("folder/page.php"); function.......... looks like to me you havent set the folder permissions to 777 or 0777 Thanks for the quick reply. Sorry I'm a bit new to PHP and stuff, please could you tell me how to change the folder permissions. Thanks muchly. Quote Link to comment Share on other sites More sharing options...
haku Posted March 5, 2008 Share Posted March 5, 2008 require_once is fine (and indeed more stable than include if the file is necessary). Your path to the included file is most likely wrong. It *could* be your permissions, but I doubt it. In what folder is the file that is calling this require function? In what folder is the file it is calling? Quote Link to comment Share on other sites More sharing options...
Matt_M Posted March 5, 2008 Author Share Posted March 5, 2008 In what folder is the file that is calling this require function? The folder that this file is in is /htdocs/ In what folder is the file it is calling? The folder that this file is in /php/ Quote Link to comment Share on other sites More sharing options...
haku Posted March 5, 2008 Share Posted March 5, 2008 And what is the function? Quote Link to comment Share on other sites More sharing options...
Matt_M Posted March 5, 2008 Author Share Posted March 5, 2008 And what is the function? This in the entire contents of the index.php file. <? require_once($DOCUMENT_ROOT . "/php/Constants.php"); require_once(PHP . "Cars.php"); require_once(PHP . "Lookup.php"); require_once(PHP . "Source.php"); require_once(PHP . "CarsBlock.php"); require_once(PHP . "NewsBlock.php"); require_once(PHP . "Error.php"); $Cars = new Cars(); // N.B. Do list unsold Cars $result = $Cars->getHotListList(); #ERR_LOG("index.php::" . '$result=' . $result); if ($result) { $source = new Source("index._htm"); $contents = $source->getText(); $hotListBlock = new CarsBlock($contents); $hotListBlock->parseHotListList($Cars); $hotListBlock->substitute($contents); // now do it again for the second block $Cars->reset(); $hotListBlock = new CarsBlock($contents); $hotListBlock->parseAllList($Cars); $hotListBlock->substitute($contents); // now do it again for the news block $lookup = new Lookup(); // N.B. Do get value $result = $lookup->getListOnName("news"); if ($result) { $block = new NewsBlock($contents); $block->parseNews($lookup); $block->substitute($contents); } print($contents); } else print("Error $result"); ?> By function do you mean require_once? I appreciate the help. Quote Link to comment Share on other sites More sharing options...
haku Posted March 5, 2008 Share Posted March 5, 2008 What is PHP equal to? Quote Link to comment Share on other sites More sharing options...
Matt_M Posted March 5, 2008 Author Share Posted March 5, 2008 What is PHP equal to? Sorry, I'm not really sure what you mean, I'm new to this. Here is the contents of the constants.php file if it is any help. <? define("PHP", $DOCUMENT_ROOT . "/php/"); ?> Quote Link to comment Share on other sites More sharing options...
haku Posted March 5, 2008 Share Posted March 5, 2008 Assuming /htdocs/ is at the same level as /php/, you need to change your require functions to look like this: require_once("../" . PHP . "Cars.php") The reason for this is because your document is in htdocs. The two periods and the slash bring you up one level to the root document, and then PHP brings you into the folder /PHP/ where 'cars.php' is located. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 5, 2008 Share Posted March 5, 2008 Do not start file paths with a / in your PHP scripts. If you use a slash at the start of a file path, PHP will try to load the file from the root of the harddrive. A / at the start of file pathss on *nix based OS's represents the root. Start your file paths with ./ instead. The dot will means current working directory. Or append the DOCUMENT_ROOT superglobal first as recommended by Matt_M <?php define('PHP', './php/'); // OR define('PHP', $_SERVER['DOCUMENT_ROOT'] . '/php/'); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.