Jump to content


read a text file into my web page

  • Please log in to reply
3 replies to this topic

#1 jimneely



  • Members
  • PipPip
  • 13 posts
  • LocationDurham, NC - USA

Posted 24 January 2014 - 07:55 AM

I have my main page set up as html. I am using php to pull in a text file. I can (on its own) read a text file but when i add the php code to the html it does not work. Help please.









@version $Id$



@copyright 2014


// Read 14 characters starting from the 21st character

//$section = file_get_contents('./people.txt', NULL, NULL, 20, 14);

//$section = file_get_contents('C:/users/jneely/desktop/test.txt', true);

//$section = file_get_contents('\\s-dmf\data\M200\TM-0731\FunctionTest\Archive\14011623595241162401B.txt', true);



= file_get_contents('//s-fs2/attachments/test.txt', true);







My html.....




= <<< EOF

<a href="http://example1.com/">QPR</a>

<br/><a href="http://example2.com/...">Deviation</a>

<br/><a href="http://example3.com/">Boundary Samples</a>

<br/><a href="http://example4.com/">TPC</a>

<br/><a href="http:readtextfile.php">Test</a>

<br/><a href="http://example6.com/">Link 6</a>






#2 cyberRobot


    Advanced Member

  • Gurus
  • 1,647 posts

Posted 24 January 2014 - 08:56 AM

Is the page named with a .php extension? Note that PHP isn't parsed in .html files...unless the server is configured to do so.

Blogging about PHP and other web development topics at ScorpBytes.com

#3 jimneely



  • Members
  • PipPip
  • 13 posts
  • LocationDurham, NC - USA

Posted 24 January 2014 - 08:06 PM

The html is a index.php that is eof and the ReadTextFile is php. Of the code submitted the first is the ReadTextFile and the second part is the EOF of my main HTML that is index.php. I hope this helps

#4 kicken


    Wiser? Not exactly.

  • Gurus
  • 2,674 posts
  • LocationBonita, FL

Posted 25 January 2014 - 10:57 AM

What exactly do you expect your anchor tag for readtextfile.php to do? If you want it to load that PHP file, you need to fix the href to actually point to that file, right now it's pointing to some non-existent http:readtextfile.php.
Recycle your old CD's, don't trash them!
Did I help you out?  Feeling generous? I accept tips via Paypal or Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime