garygas Posted August 12, 2008 Share Posted August 12, 2008 Hey! First of all let me mention that I am only a beginner when it comes to PHP, however I know a little. I have been using, until recently, the following code to include files... <?php include('http://www.mydomain.com/include1.php') ?> This worked fine until my host upgraded it's server to v.5.2.6. Now the only way around I have managed to find is to use... <?php include(realpath('E:\domains\m\mydomain.com\user\htdocs\include1.php')) ?> I have tried require() and include_once() and everything returns errors, other than include(realpath). I only use the include to bring in footers, headers, menus etc and it is not used to connect with any databased. Can anyone suggest a way that I can use the include without using the realpath?? Thanks, Gary Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/ Share on other sites More sharing options...
monkeypaw201 Posted August 12, 2008 Share Posted August 12, 2008 THey probably have the url SSI disabled.. thats what happened to me.. check the PHP.INI Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614787 Share on other sites More sharing options...
garygas Posted August 12, 2008 Author Share Posted August 12, 2008 THey probably have the url SSI disabled.. thats what happened to me.. check the PHP.INI Cheers, I am looking at it now...a little lost?? What exactly am I looking for?? Also I have just noticed this.... include_path - .;C:\php5\pear If that means anything? ??? Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614793 Share on other sites More sharing options...
revraz Posted August 12, 2008 Share Posted August 12, 2008 Can you not use include('include1.php') ? Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614799 Share on other sites More sharing options...
garygas Posted August 12, 2008 Author Share Posted August 12, 2008 Can you not use include('include1.php') ? Nope...returns this error... Warning: include() [function.include]: URL file-access is disabled in the server configuration in E:\domains\m\mydomain.com\user\htdocs\index.php on line 13 Warning: include(http://www.mydomain.com/include1.php) [function.include]: failed to open stream: no suitable wrapper could be found in E:\domains\m\mydomain.com\user\htdocs\index.php on line 13 Warning: include() [function.include]: Failed opening 'http://www.mydomain.com/include1.php' for inclusion (include_path='.;C:\php5\pear') in E:\domains\m\mydomain.com\user\htdocs\index.php on line 13 Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614802 Share on other sites More sharing options...
revraz Posted August 12, 2008 Share Posted August 12, 2008 Sounds like you are trying to include a page that is not on your site. Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614816 Share on other sites More sharing options...
monkeypaw201 Posted August 12, 2008 Share Posted August 12, 2008 THey probably have the url SSI disabled.. thats what happened to me.. check the PHP.INI Cheers, I am looking at it now...a little lost?? What exactly am I looking for?? Also I have just noticed this.... include_path - .;C:\php5\pear If that means anything? ??? Have them enable URL includes Sounds like you are trying to include a page that is not on your site. Revraz, if you notice the error: URL file-access is disabled in the server configuration Its a configuration blimp Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614818 Share on other sites More sharing options...
garygas Posted August 12, 2008 Author Share Posted August 12, 2008 I have just logged a support ticket, however it is shared hosting so no doubt they will tell me where to go! Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614822 Share on other sites More sharing options...
revraz Posted August 12, 2008 Share Posted August 12, 2008 URL Includes usually indicates you are trying to use a URL, ie http://mysite.com/path. If you just include the filename only, you shouldn't get that error. Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614834 Share on other sites More sharing options...
monkeypaw201 Posted August 12, 2008 Share Posted August 12, 2008 URL Includes usually indicates you are trying to use a URL, ie http://mysite.com/path. If you just include the filename only, you shouldn't get that error. Not necessarily, it might assume that since its relative it would input the URL automatically ??? Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614836 Share on other sites More sharing options...
revraz Posted August 12, 2008 Share Posted August 12, 2008 Anyways, tell your host to enable allow_url_fopen allow_url_include Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614837 Share on other sites More sharing options...
DarkWater Posted August 12, 2008 Share Posted August 12, 2008 URL Includes usually indicates you are trying to use a URL, ie http://mysite.com/path. If you just include the filename only, you shouldn't get that error. Not necessarily, it might assume that since its relative it would input the URL automatically ??? No, since PHP tries to use its file wrapper if possible and not instructed otherwise. Relative paths should work fine...let's wait for the OP to respond. Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614847 Share on other sites More sharing options...
revraz Posted August 12, 2008 Share Posted August 12, 2008 I know what he'll reply with, his host disabled this because it's not secure. If the file is on your site, use a relative path. If the file is on another site, use CURL. Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614855 Share on other sites More sharing options...
garygas Posted August 12, 2008 Author Share Posted August 12, 2008 Well I have logged a support ticket, so we will wait and see what they say. In the mean time they sent this out a week or so ago, before they started the upgrade to PHP5. Not sure if it indicated which direction they are going... Upgrading from PHP4 to PHP5 PHP5 has been designed to be as backwards compatable as possible with PHP4, most website will require no changes to make them compatible with PHP5 which has many features not available on earlier versions of PHP, however there are a few differences that you should be awaire of when upgrading to this version. Reserved Keywords The following keywords are now reserved: final, php user filer, interface, implements, public, private, protected, abstract, clone, try, catch, throw and this. The following keywords are no longer reserved: cfunction, and old function. A full list of reserved keywords can be found in the PHP manual at http://www.php.net/manual/en/reserved.php#reserved.keywords. Case sensitivity The values of __CLASS__, __METHOD__, and __FUNCTION__ and classes/methods of get_class(), get_parent_class() and get_class_methods() are now returned as declared, this may lead to problems in older scripts that rely on a lowercase value. Other changes array_merge() will now accept only arrays. If a non-array variable is passed, a E_WARNING will be thrown for every such parameter. The Illegal use of string offsets causes an E_ERROR rather than an E_WARNING. strrpos() and strripos() now use the entire string as a needle. The T_ML_COMMENT constant is no longer defined by the Tokenizer extension. If error_reporting is set to E_ALL, PHP will generate a notice. $_SERVER should be populated with argc and argv if variables_order includes "S". An object with no properties is no longer considered "empty". ip2long() now returns FALSE when an invalid IP address is passed as argument to the function, rather than -1. If there are functions defined in the included file, they can be used in the main file independent if they are before return() or after. If the file is included twice, PHP 5 issues fatal error because functions were already declared. register_globals has now been turned off on all Linux servers. External documents Full documentation on backward incompatibility changes can be found in the PHP manual at: http://www.php.net/manual/en/migration5.incompatible.php Further information on migrating from PHP4 to PHP5 can be found at http://www.php.net/manual/en/migration5.php The complete PHP5 manual is available at http://www.php.net/manual/en/index.php Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614856 Share on other sites More sharing options...
DarkWater Posted August 12, 2008 Share Posted August 12, 2008 And include('include1.php'); doesn't work? Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614859 Share on other sites More sharing options...
garygas Posted August 12, 2008 Author Share Posted August 12, 2008 I know what he'll reply with, his host disabled this because it's not secure. If the file is on your site, use a relative path. If the file is on another site, use CURL. I have that feeling as well...thats what I got told when I asked about turning 'register_globals' on! CURL...?? Looking at their support pages, isn't this just for Linux? BTW... I am on a Windows Server Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614860 Share on other sites More sharing options...
garygas Posted August 12, 2008 Author Share Posted August 12, 2008 And include('include1.php'); doesn't work? Nope.... previous post. Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614861 Share on other sites More sharing options...
DarkWater Posted August 12, 2008 Share Posted August 12, 2008 How about: include('file://include1.php'); And why would you use a Windows server? Linux is where it's at. And no one in their right mind would turn on register_globals, why'd you ask? Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614862 Share on other sites More sharing options...
revraz Posted August 12, 2008 Share Posted August 12, 2008 Can try file_get_contents Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614864 Share on other sites More sharing options...
garygas Posted August 12, 2008 Author Share Posted August 12, 2008 How about: include('file://include1.php'); And why would you use a Windows server? Linux is where it's at. And no one in their right mind would turn on register_globals, why'd you ask? include('file://include1.php'); doesn't work either! Windows...who knows why?? Been like that for 3-4 yrs! I wanted to turn register_globals on when I was installing osCommerce. Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614867 Share on other sites More sharing options...
revraz Posted August 12, 2008 Share Posted August 12, 2008 I still don't understand why its trying to use a URL when it's a relative path, but then again, I don't use any Windows servers. Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614871 Share on other sites More sharing options...
DarkWater Posted August 12, 2008 Share Posted August 12, 2008 include('file://include1.php'); doesn't work either! Windows...who knows why?? Been like that for 3-4 yrs! I wanted to turn register_globals on when I was installing osCommerce. Switch to Linux if you can. And I have no idea why it won't work even when forced to use the file wrapper. Never seen that before. Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614873 Share on other sites More sharing options...
garygas Posted August 12, 2008 Author Share Posted August 12, 2008 Just tried file_get_contents again... <?php $filestring = file_get_contents('http://www.mydomain.com/include1.php'); print $filestring; ?> Worked lovely!! Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614888 Share on other sites More sharing options...
DarkWater Posted August 12, 2008 Share Posted August 12, 2008 Yeah, but you can't get the PHP code to work from the file without eval()'ing it...Which is bad. Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614893 Share on other sites More sharing options...
Jabop Posted August 12, 2008 Share Posted August 12, 2008 DarkWater is the Linux equivalent of a Bible basher. Link to comment https://forums.phpfreaks.com/topic/119345-php-include-function/#findComment-614899 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.