Results 1 to 31 of 31

Thread: Storing HTML to open with PHP

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Martin County , FL
    Posts
    153

    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?!?!

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    $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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Martin County , FL
    Posts
    153
    how exactly can i open that file's entire contence (2 lines) and display it?

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    PHP Code:
    <?php
    $rs 
    fopen ("html.txt""a+");
    $contents fread($rsfilesize($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;
    ?>
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Martin County , FL
    Posts
    153
    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...

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Martin County , FL
    Posts
    153
    arggggg it's not working!!! I'll attach the files... try to debug them...
    Attached Files Attached Files

  7. #7
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Why don't you just use:

    PHP Code:
    include("file.html"); 
    My evil laugh has a squeak in it.

    kristopherwilson.com

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Martin County , FL
    Posts
    153
    because it doesnt work...

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Martin County , FL
    Posts
    153
    just wondering... did you test include ' ' with those files i attached?

  10. #10
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  11. #11
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    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 ?>
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Martin County , FL
    Posts
    153
    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...

  13. #13
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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
    My evil laugh has a squeak in it.

    kristopherwilson.com

  14. #14
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  15. #15
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    Originally posted by The Hobo


    *cough* <?php and ?> *cough*

    http://pear.php.net/manual/en/standards.tags.php
    I know, I just didnt feel like writing those three letters. Plus PHP short hand is normally enabled anyways.
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Martin County , FL
    Posts
    153
    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'

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Martin County , FL
    Posts
    153
    <?php *COUGH* ?>

    THERE!


    i do know my tags!

  18. #18
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by NewHelp4Me
    <?php *COUGH* ?>

    THERE!


    i do know my tags!
    Your point?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  19. #19
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    Man I feel like im being picked on
    even by the NewHelp4Me dude!

    j/k Next time I wont be so lazy.
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  20. #20
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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)
    My evil laugh has a squeak in it.

    kristopherwilson.com

  21. #21
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    Ha! Standards are just rules that are meant to be broken or avoided.
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  22. #22
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Notice the last word of my post...
    My evil laugh has a squeak in it.

    kristopherwilson.com

  23. #23
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    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"
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  24. #24
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  25. #25
    scoutt
    Guest
    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.

  26. #26
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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...
    My evil laugh has a squeak in it.

    kristopherwilson.com

  27. #27
    scoutt
    Guest
    then why do you listen?

  28. #28
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    i dunno, but my mommy says never to talk to strangers or boogie monsters

    *Edited* err... i wasn't looking and so one of my co-workers wrote this.
    Last edited by cpradio; Jun 14th, 2002 at 12:17 PM.
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  29. #29
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  30. #30
    scoutt
    Guest
    yeah rambling that is it all the way,

  31. #31
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    "Pappa don't preach" You remind me of that song.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width