Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    creazione pagina semi-dinamica

    Sto provando a fare girare questo script generateindex.php per trasformare la index.php in una index.html inmaniera da limitare le query al database. Però non funziona nel senso che la pagina index.html viene generata però è come se il server non fa girare il php infatti presenta il codice php nella sua sorgente. Sapete come mai? è un problema del server web? come risolvere?
    Questo è lo script che uso preso dal libro di kevin yank:
    codice:
    <?php
      // Sets the files we'll be using
      $srcurl = '/membri2/tonyz/index.php'; // This must be a URL!
      $tempfilename = 'tempindex.html';       // This must be a filename!
      $targetfilename = 'index.html';         // Also a filename!
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Generating <?php echo $targetfilename; ?></title>
    <meta http-equiv="content-type"
        content="text/html; charset=iso-8859-1" />
    </head>
    <body>
    
    
    Generating <?php echo $targetfilename; ?>...</p>
    <?php
    
      // Begin by deleting the temporary file, in case
      // it was left lying around. This might spit out an
      // error message if it were to fail, so we use
      // @ to suppress it.
      @unlink($tempfilename);
    
      // Load the dynamic page by requesting it with a
      // URL. The PHP will be processed by the Web server
      // before we receive it (since we're basically
      // masquerading as a Web browser), so what we'll get
      // is a static HTML page. The 'r' indicates that we
      // only intend to read from this "file".
      $dynpage = fopen($srcurl, 'r');
    
      // Check for errors
      if (!$dynpage) {
        exit("
    
    Unable to load $srcurl. Static page update aborted!</p>");
      }
    
      // Read the contents of the URL into a PHP variable.
      // Specify that we're willing to read up to 1MB of
      // data (just in case something goes wrong).
      $htmldata = fread($dynpage, 1024*1024);
    
      // Close the connection to the source "file", now
      // that we're done with it.
      fclose($dynpage);
    
      // Open the temporary file (creating it in the
      // process) in preparation to write to it (note
      // the 'w').
      $tempfile = fopen($tempfilename, 'w');
    
      // Check for errors
      if (!$tempfile) {
        exit("
    
    Unable to open temporary file ($tempfilename) for writing. Static page update aborted!</p>");
      }
    
      // Write the data for the static page into the
      // temporary file
      fwrite($tempfile, $htmldata);
    
      // Close the temporary file, now that we're done
      // writing to it.
      fclose($tempfile);
    
      // If we got this far, then the temporary file
      // was successfully written, and we can now copy
      // it on top of the static page.
      $ok = copy($tempfilename, $targetfilename);
    
      // Finally, delete the temporary file.
      unlink($tempfilename);
    
    ?>
    
    
    Static page successfully updated!</p>
    </body>
    </html>
    Ciao
    Tonyz
    www.staffords.it
    php work in progress database di staffordshire bull terrier(razza di cani)
    http://tonyz.altervista.org/

  2. #2
    Risolto!! Mettendo php:// davanti al nome del file da leggere così il server interpreta il php.
    www.staffords.it
    php work in progress database di staffordshire bull terrier(razza di cani)
    http://tonyz.altervista.org/

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.