el_nino Posted December 17, 2009 Share Posted December 17, 2009 hey... 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 Quote Link to comment https://forums.phpfreaks.com/topic/185457-display-content-of-a-html-file/ Share on other sites More sharing options...
rajivgonsalves Posted December 17, 2009 Share Posted December 17, 2009 what does the url looks like? is it on your own server or from some other server, if its on your server is it absolute paths or just relative ? Quote Link to comment https://forums.phpfreaks.com/topic/185457-display-content-of-a-html-file/#findComment-979111 Share on other sites More sharing options...
el_nino Posted December 17, 2009 Author Share Posted December 17, 2009 the url is on another server, it currently looks like: http://www.comp.brad.ac.uk/intranet/modules/DWT/jfs/formats.html Quote Link to comment https://forums.phpfreaks.com/topic/185457-display-content-of-a-html-file/#findComment-979113 Share on other sites More sharing options...
rajivgonsalves Posted December 17, 2009 Share Posted December 17, 2009 this include ("$url"); should be echo file_get_contents($url); ; the reason its not showing up the url is not found. Quote Link to comment https://forums.phpfreaks.com/topic/185457-display-content-of-a-html-file/#findComment-979116 Share on other sites More sharing options...
el_nino Posted December 17, 2009 Author Share Posted December 17, 2009 I tried echo file_get_contents($url); as well as replacing $url with the actual url but i'm still not getting any results. Quote Link to comment https://forums.phpfreaks.com/topic/185457-display-content-of-a-html-file/#findComment-979119 Share on other sites More sharing options...
rajivgonsalves Posted December 17, 2009 Share Posted December 17, 2009 put these lines at the very beginning of your script and see if you get any errors/notices ini_set('display_errors', '1'); error_reporating(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/185457-display-content-of-a-html-file/#findComment-979121 Share on other sites More sharing options...
el_nino Posted December 17, 2009 Author Share Posted December 17, 2009 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); Quote Link to comment https://forums.phpfreaks.com/topic/185457-display-content-of-a-html-file/#findComment-979125 Share on other sites More sharing options...
rajivgonsalves Posted December 17, 2009 Share Posted December 17, 2009 Yes that url is invalid and does not exists. Quote Link to comment https://forums.phpfreaks.com/topic/185457-display-content-of-a-html-file/#findComment-979126 Share on other sites More sharing options...
el_nino Posted December 17, 2009 Author Share Posted December 17, 2009 it must do because if i enter the url into my address bar i can see the page Quote Link to comment https://forums.phpfreaks.com/topic/185457-display-content-of-a-html-file/#findComment-979127 Share on other sites More sharing options...
getmizanur Posted December 27, 2009 Share Posted December 27, 2009 it must do because if i enter the url into my address bar i can see the page you need user name and password to access page. if you can view the page through address bar then you can be able to fetch the content. Quote Link to comment https://forums.phpfreaks.com/topic/185457-display-content-of-a-html-file/#findComment-984447 Share on other sites More sharing options...
el_nino Posted December 27, 2009 Author Share Posted December 27, 2009 problem solved... seemed to be issues with the servers at uni Quote Link to comment https://forums.phpfreaks.com/topic/185457-display-content-of-a-html-file/#findComment-984526 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.