#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Bristol, England
    Posts
    114
    Rep Power
    17

    Problem with file, file_get_contents and include in PHP 5


    Hi,

    My websites have just been moved to a PHP 5/MySql 5 server, which has caused some of my code to stop working.

    With file and file_get_contents, I get a message saying that the file couldn't be found, using this code:
    Code:
    $aRet = file("http://myothersubdomain/path/to/file/file.php")
    The file definitely exists and can be called from my browser, but file doesn't seem to be able to find it under php5.

    With include, I have a file that I include into a script and the file also has an include within it. The file itself is included, but the include within the file is not. It seems to be executed, but nothing replaces it.

    The first file is:
    Code:
    <html>
    <head>
    <title>Download Login</title>
    <meta name="Keywords" content="download,login" />
    <meta name="Description" content="Download Login" />
    <meta http-equiv="robots" content="noindex, nofollow" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta http-equiv="Content-Language" content="en-us" />
    <link href="http://myothersubdomain/path/to/file/css.php" rel="stylesheet" type="text/css" />
    <script language="JavaScript1.2" type="text/javascript" src="js/constants.js.php"></script>
    </head>
    <body background="http://myothersubdomain/images/bg.jpg">
    <table width="750" align="center" valign="top" cellpadding="0" cellspacing="0" class="page-border">
    <tr><td align="center">
    	<img name="imghdr" src="http://myothersubdomain/images/hdr.gif" width="750" height="100" border="0" />
    
    	<table width="100%" align="center" valign="top" border="0" cellpadding="10" cellspacing="0" class="bg-page">
    	<tr><td valign=top>
    		<h1>Download Login</h1>
    		<?php $booShowFieldset = TRUE; ?><?php include("http://myotherdomain/path/to/file/myfile.htm"); ?>
    	</td></tr></table>
    	<?php include("http://myothersubdomain/path/to/file/myfile2.htm"); ?>
    </td></tr></table>
    </body>
    </html>
    The code that executes it is:
    Code:
    $strEvalFilename = "/home/path/to/file/myincludefile.php";
    ob_start();
    include($strEvalFilename);
    $strEvalText = ob_get_clean();
    The result is:
    Code:
    <html>
    <head>
    <title>Download Login</title>
    <meta name="Keywords" content="download,login" />
    <meta name="Description" content="Download Login" />
    <meta http-equiv="robots" content="noindex, nofollow" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta http-equiv="Content-Language" content="en-us" />
    <link href="http://myothersubdomain/path/to/file/css.php" rel="stylesheet" type="text/css" />
    <script language="JavaScript1.2" type="text/javascript" src="js/constants.js.php"></script>
    </head>
    <body background="http://myothersubdomain/images/dpp-bg.jpg">
    <table width="750" align="center" valign="top" cellpadding="0" cellspacing="0" class="page-border">
    <tr><td align="center">
    	<img name="imghdr" src="http://myothersubdomain/images/hdr.gif" width="750" height="100" border="0" />
    
    	<table width="100%" align="center" valign="top" border="0" cellpadding="10" cellspacing="0" class="bg-page">
    	<tr><td valign=top>
    		<h1>Download Login</h1>
    			</td></tr></table>
    	</td></tr></table>
    </body>
    </html>
    Could anyone tell me whether these statements have changed in the way they operate in php5 that would cause this behaviour and what I can do to fix it? All 3 statements have worked fine in php4 and nothing changed code-wise before or after the migration to php5.

    Debbie
    QuicknEasySalesPro.com
    - your quick and easy, yet powerful solution for managing your
    membership site sales, downloads and affiliates.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Nov 2003
    Posts
    1,754
    Rep Power
    69
    Its probably just a setting that has been changed when php5 was compiled. Try checking the allow_url_fopen setting in the php.ini. By default it is set to 1 which is what you need but obviously it could of been changed.

    Comments on this post

    • lnxgeek agrees
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Bristol, England
    Posts
    114
    Rep Power
    17
    Hi Andrew_Smart,

    I forgot to say, I did check the allow_url... settings and they are both on.

    Debbie
    QuicknEasySalesPro.com
    - your quick and easy, yet powerful solution for managing your
    membership site sales, downloads and affiliates.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Bristol, England
    Posts
    114
    Rep Power
    17
    Hi,

    FYI, for anyone with a similar problem. I solved this problem by asking my hoster to switch allow_url_include on and everything is working again.

    Debbie

    Comments on this post

    • lnxgeek agrees
    QuicknEasySalesPro.com
    - your quick and easy, yet powerful solution for managing your
    membership site sales, downloads and affiliates.

IMN logo majestic logo threadwatch logo seochat tools logo