Jump to content

Display content of a HTML file


el_nino

Recommended Posts

hey... ;D

 

I have a postgreSQL database which contains URL's to HTML documents. I want to output the contents of this document on a particular page on my site. so far i have tried 'file_get_contents', 'include' and 'fopen' but dont seem to be getting anywhere. The code i am using is

 

<?php
            $sql="select * from jfs where issue = (select max(issue) from jfs) and format = 'html'";// selects the latest issue


            $result_set = pg_Exec ($conn, $sql);
            $rows = pg_NumRows($result_set);

            if ((!$result_set) || ($rows < 1)) {
                  echo "<H1>ERROR - no rows returned</H1><P>";
                  exit;  //exit the script
                  }

            for ($j=0; $j < $rows; $j++)
               {
               $issue = pg_result($result_set, $j, "issue");
               $page = pg_result($result_set, $j, "page");
               $author = pg_result($result_set, $j, "author");
               $title = pg_result($result_set, $j, "title");
               $format = pg_result($result_set, $j, "format");
               $url = pg_result($result_set, $j, "url");   

			//$url="http://google.co.uk/";
			//$home=readfile($url);
			include ("$url");
			//echo $home;



               }
?> 

<?php
        pg_FreeResult($result_set);
        pg_Close($conn);
?>

 

i know that my query my working as i am able to echo the url but cannot display the contents of the file

 

any help would be greatley appreciated

 

el nino

Link to comment
https://forums.phpfreaks.com/topic/185457-display-content-of-a-html-file/
Share on other sites

thanks for that...ok so i now get the following error

 

Warning: file_get_contents(http://www.comp.brad.ac.uk/intranet/modules/DWT/jfs/formats.html) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in *file location* on line 54

 

line 54 is:

echo file_get_contents($url);

 

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.