Jump to content

Problem with file, file_get_contents and include in PHP 5


Debbie-Leigh

Recommended Posts

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:

$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:

<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:

$strEvalFilename = "/home/path/to/file/myincludefile.php";
ob_start();
include($strEvalFilename);
$strEvalText = ob_get_clean();

The result is:

<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

 

Link to comment
Share on other sites

  • 2 weeks later...
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.