Jump to content

Why is this not working when put in a variable?


WaxyChicken
Go to solution Solved by Barand,

Recommended Posts

this works:


echo("</table>");
echo("<br><BR><BR><BR>");
echo("URL file = ");
echo($urlFile);
echo("<BR>");
$urlFile = "" . $_GET['urlFile'];
echo("$get urlfile = ");
echo("*" . $urlFile . "*");
echo("<HR>");
echo ("Current Directory: " . getcwd() . "\n<BR>");
if ($urlFile = "")
{
	$urlFile = "index.html";
}



//$fh = fopen("index.html", 'r');
$fh = fopen("index.html", 'r');
$theData = fread($fh, filesize("index.html"));
fclose($fh);
echo $theData;

this does not....


echo("</table>");
echo("<br><BR><BR><BR>");
echo("URL file = ");
echo($urlFile);
echo("<BR>");
$urlFile = "" . $_GET['urlFile'];
echo("$get urlfile = ");
echo("*" . $urlFile . "*");
echo("<HR>");
echo ("Current Directory: " . getcwd() . "\n<BR>");
if ($urlFile = "")
{
	$urlFile = "index.html";
}



//$fh = fopen("index.html", 'r');
$fh = fopen($urlFile, 'r');
$theData = fread($fh, filesize($urlFile));
fclose($fh);
echo $theData;

the dubug output is the same:

 

urlfile = *index.html*

Current Directory: c:\inetpub\wwwroot

 

 

the errors it throws are:

 

[phpBB Debug] PHP Warning: in file C:/inetpub/wwwroot/frametest.php on line 279: fopen(): Filename cannot be empty
[phpBB Debug] PHP Warning: in file C:/inetpub/wwwroot/frametest.php on line 280: fread() expects parameter 1 to be resource, boolean given
[phpBB Debug] PHP Warning: in file C:/inetpub/wwwroot/frametest.php on line 281: fclose() expects parameter 1 to be resource, boolean given

 

how can $urlFile be the same in both examples, but not the name of a file in the second example?

i'm using
$urlFile = "" . $_GET['urlFile'];
for the second example.   eg: http://www.MYSITE.com/myPHPscript.php?urlFile=index.html
Edited by WaxyChicken
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.