MasterACE14 Posted August 30, 2009 Share Posted August 30, 2009 Hello, I have my script setup like the following... <?php // main file // include GET engine require_once("C:\wamp\www\GETengine\index.php"); // start require_once("start.php"); require_once("includes.php"); // HTML compression if($config['htmlcompress'] == 1) ob_start( 'ob_gzhandler' ); ?> <!-- HTML... header.. left panel etc --> <div id="content"> </div> in the #content div, a PHP file is loaded with the use of AJAX depending on what link was clicked. However what I have at the top with the 3 require_once()'s they aren't included in whatever PHP file is loaded in the #content div. Is there a way so I can include those 3 files in each page loaded in #content, without actually copy & pasting that into each individual PHP file? Any help/info/suggestions are appreciated. Regards, Ace Link to comment https://forums.phpfreaks.com/topic/172462-solved-require_once-with-ajax/ Share on other sites More sharing options...
trq Posted August 30, 2009 Share Posted August 30, 2009 Call require_once within the scripts that are being requested via ajax. Link to comment https://forums.phpfreaks.com/topic/172462-solved-require_once-with-ajax/#findComment-909231 Share on other sites More sharing options...
MasterACE14 Posted August 30, 2009 Author Share Posted August 30, 2009 I've just changed the files so require_once is called within the scripts like you suggested. // include GET engine require_once("../GETengine-1.0.0/index.php"); // start require_once("../start.php"); require_once("../includes.php"); that works fine for the last 2. But for the GET engine I'm getting a error I haven't encountered before :S Fatal error: Uncaught exception 'InvalidArgumentException' with message 'The given path is not a directory.' in C:\wamp\www\newcf\GETengine-1.0.0\includes\functions.php:51 Stack trace: #0 C:\wamp\www\newcf\gamefunctions.php(2): getDirectoryTree('gamefunctions') #1 C:\wamp\www\newcf\includes.php(2): require_once('C:\wamp\www\new...') #2 C:\wamp\www\newcf\lib\home.php(6): require_once('C:\wamp\www\new...') #3 {main} thrown in C:\wamp\www\newcf\GETengine-1.0.0\includes\functions.php on line 51 Link to comment https://forums.phpfreaks.com/topic/172462-solved-require_once-with-ajax/#findComment-909237 Share on other sites More sharing options...
trq Posted August 30, 2009 Share Posted August 30, 2009 What does line 51 of... C:\wamp\www\newcf\GETengine-1.0.0\includes\functions.php look like? Link to comment https://forums.phpfreaks.com/topic/172462-solved-require_once-with-ajax/#findComment-909238 Share on other sites More sharing options...
MasterACE14 Posted August 30, 2009 Author Share Posted August 30, 2009 throw new InvalidArgumentException('The given path is not a directory.'); It's apart of the Get Directory Tree function. function getDirectoryTree($path, $directorySeparator = "/", $startPath = null) { if (!is_dir($path)) { throw new InvalidArgumentException('The given path is not a directory.'); } if (null === $startPath) { $startPath = $path; } $startPathLength = strlen($startPath) + 1; $items = array(); foreach (new DirectoryIterator($path) as $item) { if ($item->isDot()) continue; if ($item->isDir()) { $items = array_merge($items, getDirectoryTree($item->getPathname(), $directorySeparator, $startPath)); } else { $name = substr($item->getPathName(), $startPathLength); if ($directorySeparator !== DIRECTORY_SEPARATOR) { $name = str_replace(DIRECTORY_SEPARATOR, $directorySeparator, $name); } $items[] = $name; } } return $items; } Link to comment https://forums.phpfreaks.com/topic/172462-solved-require_once-with-ajax/#findComment-909239 Share on other sites More sharing options...
MasterACE14 Posted August 30, 2009 Author Share Posted August 30, 2009 I've echo'd out the file path which it says is not a directory, and the path is correct. Fatal error: Uncaught exception 'InvalidArgumentException' with message 'The given path is not a directory.' C:\wamp\www\newcf\GETengine-1.0.0\modules Link to comment https://forums.phpfreaks.com/topic/172462-solved-require_once-with-ajax/#findComment-909250 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.