Jun 13th, 2002, 04:35 PM
#1
Thread Starter
Addicted Member
Storing HTML to open with PHP
Ok. So i have Condition.php and it opens a text file that has some HTML that gets changed frequently. condition.php displays that text file and since the text file has HTML inside of it Condidion.php displays the text file as HTML. with me still? For some reason it displays "Resource ID#1" instead of what it is supposed to display.
Here's the code i used to open the file and store it as a variable:
PHP Code:
$rs = fopen ( "html.txt" , "r" );
fclose ( $rs ); ?>
Here is the code i used to recall the variable:
PHP Code:
<?php echo $rs ; ?>
what's wrong with it? It displays Resource ID#1 instead of displaying what it is supposed to.
PLEASE DEbug it for me?!?!
Jun 13th, 2002, 05:11 PM
#2
PowerPoster
$rs is a file pointer, it doesn't contain the contents of that file
You have to read it in using a function like fgets
See this for file reading functions
Jun 13th, 2002, 05:23 PM
#3
Thread Starter
Addicted Member
how exactly can i open that file's entire contence (2 lines) and display it?
Jun 13th, 2002, 10:00 PM
#4
Stuck in the 80s
PHP Code:
<?php
$rs = fopen ( "html.txt" , "a+" );
$contents = fread ( $rs , filesize ( $rs ));
fclose ( $rs );
echo $contents ;
?>
or, if you simply want to display the contents and do nothing else:
PHP Code:
<?php
$contents = implode ( "\n" , file ( "html.txt" ));
echo $contents ;
?>
Jun 14th, 2002, 07:50 AM
#5
Thread Starter
Addicted Member
It all comes together... should have researched on implode... then mabe i would have come up with that on my own... Balancing VB, Basic C+, and My web server's need get's you no where... Cus you never become a pro at any...
Jun 14th, 2002, 07:59 AM
#6
Thread Starter
Addicted Member
arggggg it's not working!!! I'll attach the files... try to debug them...
Attached Files
Jun 14th, 2002, 10:07 AM
#7
Stuck in the 80s
Why don't you just use:
PHP Code:
include( "file.html" );
Jun 14th, 2002, 10:20 AM
#8
Thread Starter
Addicted Member
because it doesnt work...
Jun 14th, 2002, 10:26 AM
#9
Thread Starter
Addicted Member
just wondering... did you test include ' ' with those files i attached?
Jun 14th, 2002, 10:29 AM
#10
Stuck in the 80s
Originally posted by NewHelp4Me
because it doesnt work...
Yes...it does. You just don't know what you're doing.
This is elementary stuff. I'd hate to see what would happen if you ever tried to go on in VB or PHP if you can't accomplish this.
Jun 14th, 2002, 10:30 AM
#11
Fanatic Member
any error messages when you try using include ("html.txt"); or include ("file.html"); ?
Do you have a link I can view where you are trying to test the page?
And are you giving the page that is using th php code a .php, .php3 or .phtml extension
And are you surrounding the php code with <? and ?>
Jun 14th, 2002, 10:32 AM
#12
Thread Starter
Addicted Member
sorry i was being a dumbass... i got it to work... I was trying
PHP Code:
$htmlstuff = include 'html.txt'
echo $htmlstuff
it wasn't displaying anything...
Jun 14th, 2002, 10:32 AM
#13
Stuck in the 80s
Originally posted by cpradio
any error messages when you try using include ("html.txt"); or include ("file.html"); ?
Do you have a link I can view where you are trying to test the page?
And are you giving the page that is using th php code a .php, .php3 or .phtml extension
And are you surrounding the php code with <? and ?>
*cough* <?php and ?> *cough*
http://pear.php.net/manual/en/standards.tags.php
Jun 14th, 2002, 10:33 AM
#14
Stuck in the 80s
Originally posted by NewHelp4Me
sorry i was being a dumbass... i got it to work... I was trying
PHP Code:
$htmlstuff = include 'html.txt'
echo $htmlstuff
it wasn't displaying anything...
Are you sure it's working this time, or are you going to post again in 10 minutes saying it isn't?
Jun 14th, 2002, 10:35 AM
#15
Fanatic Member
I know, I just didnt feel like writing those three letters. Plus PHP short hand is normally enabled anyways.
Jun 14th, 2002, 10:35 AM
#16
Thread Starter
Addicted Member
alas..
my webserver is conpleted! http://wnvm.mine.nu :
go through the cheep flash video i made click welcome (it only redirects after you take your cursor off the button *found it tricky*) and click 'check this server's condition'
Jun 14th, 2002, 10:38 AM
#17
Thread Starter
Addicted Member
<?php *COUGH* ?>
THERE!
i do know my tags!
Jun 14th, 2002, 10:40 AM
#18
Stuck in the 80s
Originally posted by NewHelp4Me
<?php *COUGH* ?>
THERE!
i do know my tags!
Your point?
Jun 14th, 2002, 10:40 AM
#19
Fanatic Member
Man I feel like im being picked on
even by the NewHelp4Me dude!
j/k Next time I wont be so lazy.
Jun 14th, 2002, 10:41 AM
#20
Stuck in the 80s
Originally posted by cpradio
I know, I just didnt feel like writing those three letters. Plus PHP short hand is normally enabled anyways.
But not suggested. You gotta follow the standards man! (sarcasm)
Jun 14th, 2002, 10:45 AM
#21
Fanatic Member
Ha! Standards are just rules that are meant to be broken or avoided.
Jun 14th, 2002, 10:46 AM
#22
Stuck in the 80s
Notice the last word of my post...
Jun 14th, 2002, 10:47 AM
#23
Fanatic Member
Originally posted by The Hobo
Notice the last word of my post...
I noticed. Im just adding to it. Im down with avoiding these so called "Standards"
Jun 14th, 2002, 10:49 AM
#24
Stuck in the 80s
Most make sense to me. Some are just plain retarded. Like making sure there's x number of spaces between your variable and the equal sign so it matches all the others. Give me a break.
Jun 14th, 2002, 11:13 AM
#25
boy, I hope scoutt doesn't read this thread..... DOH!
yeah boycott standards.
oh and it is recommended to use the <?php with the php on htere because of other languages that use the <? so just to keep under your hat.
I thought the same way as you, but it could be disasteres.
Jun 14th, 2002, 11:45 AM
#26
Stuck in the 80s
Originally posted by scoutt
boy, I hope scoutt doesn't read this thread..... DOH!
yeah boycott standards.
oh and it is recommended to use the <?php with the php on htere because of other languages that use the <? so just to keep under your hat.
I thought the same way as you, but it could be disasteres.
You talk too much...
Jun 14th, 2002, 11:46 AM
#27
Jun 14th, 2002, 12:07 PM
#28
Jun 14th, 2002, 10:43 PM
#29
Stuck in the 80s
Originally posted by scoutt
then why do you listen?
I didn't. I just saw that you posted again and assumed you were rambling once again. *reads the post* yeah.
Jun 15th, 2002, 08:46 PM
#30
yeah rambling that is it all the way,
Jun 15th, 2002, 10:22 PM
#31
Stuck in the 80s
"Pappa don't preach" You remind me of that song.
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width