Computer Science Canada Dispay text files |
Author: | da_foz [ Fri Oct 01, 2004 7:48 pm ] | ||
Post subject: | Dispay text files | ||
Ok, here is what I want to do. I have a directory with a bunch of *.txt files in it. What I want is to generate a list of all the file names, and places them on a page. The list will be links, so that when you click on one of them, the *.txt file will be displayed. Now the part I am having trouble with. What I want is for the *.txt file to be displayed on the same page as the the list of files, but underneath. (ie, like this http://www.redclaw.ca/funnypics.php ). I got it working for the pics page, but I can't get it working for the 'text jokes'. Here is the code I am using for the pics page:
The problem I'm having modifying this code is that I think I will have to read in the *.txt line by line and then output it, and I just can't get it to work. I've spent much time on the PHP website working on this. Any help would be great. Thanks. |
Author: | wtd [ Fri Oct 01, 2004 8:02 pm ] | ||
Post subject: | |||
What about using include() to insert the text of the document?
|
Author: | da_foz [ Fri Oct 01, 2004 8:11 pm ] | ||
Post subject: | |||
Ok, I tried that here: http://www.redclaw.ca/textjokes.php Try clicking on one of the options and see so that you can see the error.
|
Author: | wtd [ Fri Oct 01, 2004 8:18 pm ] |
Post subject: | |
Try using the full path to that directory. |
Author: | rdrake [ Fri Oct 01, 2004 8:24 pm ] | ||
Post subject: | |||
Does
|
Author: | da_foz [ Fri Oct 01, 2004 8:26 pm ] | ||
Post subject: | |||
cartoon_shark wrote: Does
That generate this error: Warning: main(): Unable to access /jokes/ in /home/virtual/site118/fst/var/www/html/textjokes.php on line 134 Warning: main(/jokes/): failed to open stream: No such file or directory in /home/virtual/site118/fst/var/www/html/textjokes.php on line 134 Warning: main(): Failed opening '/jokes/' for inclusion (include_path='.:/php/includes:/usr/share/php:/usr/share/pear') in /home/virtual/site118/fst/var/www/html/textjokes.php on line 134 Oh, and I changed the dir 'funPics' to 'jokes' which is what it should be. |
Author: | da_foz [ Fri Oct 01, 2004 8:27 pm ] |
Post subject: | |
I know I have access to the dir as if I try going to it directly I get it. http://www.redclaw.ca/jokes/City_Boy.txt |
Author: | da_foz [ Fri Oct 01, 2004 8:28 pm ] |
Post subject: | |
wtd wrote: Try using the full path to that directory.
Did not seem to change anything. |
Author: | Blade [ Sat Oct 02, 2004 3:07 pm ] | ||||
Post subject: | |||||
okay. there are two ways i'd do this: include the file, or use an iframe. including i dont like because when you include the text file, it usually doesnt show the new lines where they're supposed to be. using an iframe does that, and it lets you scroll down. i made 2 test pages and you can check them out here. include: http://uifgames.8-bit.ca/scripts/txtindex.php
iframe: http://uifgames.8-bit.ca/scripts/txtindex.php
go into http://uifgames.8-bit.ca/scripts to see the files and directory as for your including problem.. the directory you are pointing to doesnt exist... so yer obviously gonna have to fix your paths |
Author: | da_foz [ Sat Oct 02, 2004 3:10 pm ] |
Post subject: | |
Ok, I used that exect code only making a change for my directory name. Please go here to see the error: http://www.redclaw.ca/textjokes.php?pg=City_Boy.txt I'm thinking I will contact my host as this is really pissing me off. I know the file is there, it was found to generate the list! ARG! Thanks for all the help people. If you can thing of what may be causing this error please let me know. |