WaxyChicken Posted October 5, 2015 Share Posted October 5, 2015 (edited) 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 October 5, 2015 by WaxyChicken Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted October 5, 2015 Solution Share Posted October 5, 2015 this line if ($urlFile = "") sets the $urlFile to '' You need the comparison operator "==" and not the assignment operator "=" Quote Link to comment Share on other sites More sharing options...
WaxyChicken Posted October 5, 2015 Author Share Posted October 5, 2015 BINGO! thank you. it was the result of me not having PHP as my first language. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.