Hello. I am having problems using the static home page trick Kevin showed us on the PHP/MySQL tutorial. Here's my code:
And here's my problem:Code:<!-- generateindex.php --> <?php // Sets the files we'll be using $srcurl = "http://www.tweakpro.com/index.php"; $tempfilename = "/home/www/pedro_gb/tweakpro.com/docs/tempindex.html"; $targetfilename = "/home/www/pedro_gb/tweakpro.com/docs/index.html"; ?> <HTML> <HEAD> <TITLE>TweakPro.com Administration</TITLE> </HEAD> <BODY> <?php require("header.html");?> <P>Generating <?php echo("$targetfilename"); ?>...</P> <?php @unlink($tempfilename); $dynpage = fopen($srcurl, 'r'); if (!$dynpage) { echo("<P>Unable to load $srcurl. Static page ". "update aborted!</P>"); exit(); } $htmldata = fread($dynpage, 1024*1024); fclose($dynpage); $tempfile = fopen($tempfilename, 'w'); if (!$tempfile) { echo("<P>Unable to open temporary file ". "($tempfilename) for writing. Static page ". "update aborted!</P>"); exit(); } fwrite($tempfile, $htmldata); fclose($tempfile); $ok = copy($tempfilename, $targetfilename); unlink($tempfilename); ?> <P>Static page successfully updated!</P> </BODY> </HTML>
If I set $srcurl as the hard drive path, it works but instead of the content ending up as the dynamically generated page, it ends up as the actual code.
If I set $srcurl as http://localhost/index.php it gives me this:
Warning: fopen("http://localhost/index.php","r") - Connection refused in /home/www/pedro_gb/tweakpro.com/docs/admin/generateindex.php on line 17
And, finally, if I set $srcurl as http://www.tweakpro.com it gives me this:
Warning: fopen("http://www.tweakpro.com/index.php","r") - Undefined error: 0 in /home/www/pedro_gb/tweakpro.com/docs/admin/generateindex.php on line 17
What could be wrong? Thanks in advance!





Bookmarks