Kolusion Posted August 20, 2011 Share Posted August 20, 2011 I am wanting HTML to render within a table and sourcing the data from another file. In an attempt to do this, I tried: <TABLE class="main"> <TR> <TD> <?php readfile('./1/index.html'); ?> </TD> </TR> </TABLE> This does not work and I am wondering if anyone knows how it can be done - or even if it can be done? Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/ Share on other sites More sharing options...
titan21 Posted August 20, 2011 Share Posted August 20, 2011 try require_once(), require(), include() or include_once(). Have a look at http://uk.php.net/manual/en/function.require.php Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259732 Share on other sites More sharing options...
Kolusion Posted August 20, 2011 Author Share Posted August 20, 2011 That link is 404. I tried: <TABLE class="main"> <TR> <TD> <?php include('./1/index.html'); ?> </TD> </TR> </TABLE> .. but it didn't work. Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259734 Share on other sites More sharing options...
titan21 Posted August 20, 2011 Share Posted August 20, 2011 Try this... <TABLE class="main"> <TR> <TD> <?php include($_SERVER['DOCUMENT_ROOT'].'/1/index.html'); ?> </TD> </TR> </TABLE> You need to specify exactly where the file is located. Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259740 Share on other sites More sharing options...
Kolusion Posted August 20, 2011 Author Share Posted August 20, 2011 I assumed the target './1/index.html' would have specified the file location - where "." specifies !!<<from this directory>>!! I tried your code but it didn't work. Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259745 Share on other sites More sharing options...
titan21 Posted August 20, 2011 Share Posted August 20, 2011 Can you let us know the absolute path of your server root (i.e. where your index.htm file is located) and then the absolute path of the file you are trying to include. Hopefully, we'll be able to construct a correct line of code for you. Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259751 Share on other sites More sharing options...
Kolusion Posted August 20, 2011 Author Share Posted August 20, 2011 Sure, The root path is: /var/www/test1.com/ The include\readfile path (the file I want being rendered into the table: /var/www/test1.com/products/1/index.html The HTML file in reference that holds the table called "main" we are talking about is: /var/www/test1.com/products/index.html Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259755 Share on other sites More sharing options...
titan21 Posted August 20, 2011 Share Posted August 20, 2011 Okay, Try this: <TABLE class="main"> <TR> <TD> <?php include($_SERVER['DOCUMENT_ROOT'].'/products/1/index.html'); ?> </TD> </TR> </TABLE> Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259758 Share on other sites More sharing options...
Kolusion Posted August 20, 2011 Author Share Posted August 20, 2011 Already tried that before mate. Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259759 Share on other sites More sharing options...
titan21 Posted August 20, 2011 Share Posted August 20, 2011 Am a bit stumped! :-\ is it a permissions issue? Can you check that everyone has read access to this file? Have u tried calling the file directly into the browser? Is there anything in the logs which give a clue? Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259764 Share on other sites More sharing options...
Kolusion Posted August 20, 2011 Author Share Posted August 20, 2011 When I paste the code outside a HTML table, it works fine. Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259768 Share on other sites More sharing options...
titan21 Posted August 20, 2011 Share Posted August 20, 2011 That's not it. PHP won't have a clue where it is in relation to the HTML. Did you check the logs and permissions? Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259769 Share on other sites More sharing options...
Kolusion Posted August 20, 2011 Author Share Posted August 20, 2011 Fuck. hold up shits got messy. Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259771 Share on other sites More sharing options...
Kolusion Posted August 20, 2011 Author Share Posted August 20, 2011 Please ignore my last two posts. Ok, where can I check PHP log files? Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259772 Share on other sites More sharing options...
Kolusion Posted August 20, 2011 Author Share Posted August 20, 2011 Here is something that enforces my original thought. <?php include('./1/index.html'); ?> When I put this code into its own .php file an run it, it works. So the code is valid. Now to the question, why won't it work inside a table? Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259774 Share on other sites More sharing options...
titan21 Posted August 20, 2011 Share Posted August 20, 2011 If you're running apache then the logs should be at /var/log/apache/error.log. Is this your webserver or soemone elses? Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259776 Share on other sites More sharing options...
Kolusion Posted August 20, 2011 Author Share Posted August 20, 2011 No problem in error.log and access.log shows it didn't even try to fetch '/1/index.html'. <?php include('./1/index.html'); ?> .. is also showing up in the HTML source code via my browser. Is that normal? Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259779 Share on other sites More sharing options...
titan21 Posted August 20, 2011 Share Posted August 20, 2011 Can you post the entire HTML? Popping out now but will be back later. Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259783 Share on other sites More sharing options...
Kolusion Posted August 20, 2011 Author Share Posted August 20, 2011 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <TITLE>X</TITLE> <META content="charset=windows-1252;text/html" http-equiv="content-type"> <STYLE type="text/css"> BODY { background-attachment:fixed; background-image:url("/bodybackground.png"); background-position:center; background-repeat:no-repeat; font-family:verdana } IMG.logo { left:50%; margin-left:-635px; margin-top:-355px; position:absolute; top:50% } SPAN.accountmenu { left:50%; margin-left:589px; margin-top:-352px; position:absolute; top:50% } SPAN.mainmenu { left:50%; margin-left:374px; margin-top:-331px; position:absolute; top:50% } A.silver { color:silver; } TABLE.main { background-color:gold; height:636px; left:50%; margin-left:-635px; margin-top:-307px; position:absolute; top:50%; width:1270px } A.legal { color:silver; left:50%; margin-left:-90px; margin-top:334px; position:absolute; top:50% } </STYLE> <DIV> <IMG alt="" class="logo" src="../../../logo.png"> <SPAN class="accountmenu"> <A class="silver" href="/login">Login</A> </SPAN> <SPAN class="mainmenu"> <A class="silver" href="/contact">Contact</A> | <A class="silver" href="/information">Information</A> | <A class="silver" href="/products">Products</A> </SPAN> <TABLE class="main"> <TR> <TD> <?php include('./1/index.html'); ?> </TD> </TR> </TABLE> <A class="legal" href="/legal">© X 2012</A> </DIV> Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259784 Share on other sites More sharing options...
Kolusion Posted August 20, 2011 Author Share Posted August 20, 2011 Just to let you know, the code above has been fragmented by this website. The untouched file is hosted here: http://www.qfpost.com/download.do?get=1fe261dc5fa32a907c8cb2b4cd7ac354 Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259785 Share on other sites More sharing options...
titan21 Posted August 20, 2011 Share Posted August 20, 2011 Try renaming the file index.php not index.html. You can keep the included file as index.html as long as there is no PHP to process in it - otherwise that will need renaming to index.php also! Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259803 Share on other sites More sharing options...
codefossa Posted August 20, 2011 Share Posted August 20, 2011 If you're tryin' to show the HTMl from the page, you need to require it, not include it. require("1/index.html"); Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259805 Share on other sites More sharing options...
Kolusion Posted August 20, 2011 Author Share Posted August 20, 2011 Hey dude, haha yeah the problems resolved now. What I actually did was allow .html files to be executed as PHP from httpd.conf (Apache) Thanks anyhow! Quote Link to comment https://forums.phpfreaks.com/topic/245272-displaying-content-inside-a-table-sourced-via-readfile/#findComment-1259879 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.