Jodz Posted January 16, 2007 Share Posted January 16, 2007 I'm using ajax so that a website im designing doesnt refresh when u navigate around it. http://www.eactestsite.com/web/kumbait calls information from a file called ajaxcontent.php and is displayed via a php include the the index.php file. Thing is when i use an include within the ajaxcontent.php the page breaks and will only load up to the point where the include is in the index file. I just can't seem to get it to work.Any help would be much appreciated!cheers,Jodz. Link to comment https://forums.phpfreaks.com/topic/34394-php-include-within-php-include/ Share on other sites More sharing options...
utexas_pjm Posted January 16, 2007 Share Posted January 16, 2007 My guess is that the path / filename you've passed to the include construct is not correct. Is ajaxcontent.php in the same directory as index.php? If it's not then the includes within ajaxcontent.php must be relative to index.php not ajaxcontent.php. I'll try to be illustrate this with a small example.Consider a directory structure like this:/root/index.php/root/src/somescript.php/root/lib/someclass.php[b]index.php[/b][code]<?phpinclude('src/somescript.php');// ..?>[/code][b]somescript.php[/b][code]<?php// This won't work, as it's relative to somescript.php// include('../lib/someclass.php');// This will because it's relative to index.php.include('lib/someclass.php');?>[/code]Generally I find it easier to include everything in one file on the root directory. [b]global.php[/b][code]<?phpinclude('lib/someclass.php');include('lrc/somescript.php');?>[/code]I hope this helps.Best,Patrick Link to comment https://forums.phpfreaks.com/topic/34394-php-include-within-php-include/#findComment-161950 Share on other sites More sharing options...
Jodz Posted January 16, 2007 Author Share Posted January 16, 2007 all the files are in the root directory, I just can't seem to get it to work! :-[ thanks for the quick reply tho!Anymore ideas? Link to comment https://forums.phpfreaks.com/topic/34394-php-include-within-php-include/#findComment-161985 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.