Jump to content

PHP Include Function


garygas

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

How about:

 

include('file://include1.php');

 

And why would you use a Windows server?  Linux is where it's at. :D  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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.