SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member n8cz's Avatar
    Join Date
    May 2003
    Location
    USA
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Semi-Dynamic Pages from Ch. 10

    I've been using kyank's php/mysql book, and from Ch. 10 I tried out the generateindex.php. After running the script (altered to create a static page called POL180.html), no errors were shown, just "Generating POL180.html... Static page successfully updated!" Unfortunately I can't find were POL180.html was saved. I origianally assumed that it would be saved to the same directory as 'generateindex.php', but that is not the case. Is there a way to specify what directory I want the static page to be saved in? (It's running on a linux server.) Any help would be appreciated.

    - n8

  2. #2
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you really should post some code since I (and many others) do not own this book ...
    - website

  3. #3
    SitePoint Member n8cz's Avatar
    Join Date
    May 2003
    Location
    USA
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry, here you go...

    PHP Code:
    <!-- generateindex.php -->
    <?php

    $srcurl 
    "http://mydomain.com/products/product.php?psc=$psc";
    $tempfilename "$psc.html";
    $targetfilename "$psc.html";
    ?>

    <html>
    <head>
    <title> Generating <?=$targetfilename?> </title>
    </head>
    <body>
    <p>Generating <?=$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($dynpage1024*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>
    Last edited by n8cz; May 23, 2003 at 12:24.

  4. #4
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    did you define $psc ?

    Else I don't see what is wrong, is there simply no .html file in the directory ?
    - website

  5. #5
    SitePoint Member n8cz's Avatar
    Join Date
    May 2003
    Location
    USA
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, I'm an idiot...

    $tempfilename
    $targetfilename

    need to be named differently... works fine now. Apparently it was creating the temp file & then deleting the targetfile because they were named the same thing. So, when the script deleted the temp file, it deleted the target file as well.

    thanks for the help anyway.
    n8


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •