SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    <?php include ('anything.html'); ?> [ won't work]

    i have included that piece of code:

    <?php include ('anything.html'); ?> and the page does not display onto the html page I have

    this is sorta like an iframe

    why won't it work?

  2. #2
    SitePoint Zealot reinspire's Avatar
    Join Date
    Jun 2005
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?php require('anything.html'); ?>

    That'll cover it

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that does not work either, what the f*k is goin on here..

  4. #4
    SitePoint Zealot mike.fro's Avatar
    Join Date
    Jun 2005
    Location
    Lewisville, Texas
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Show us the full code...and show us the anything.html or whatever file your trying to include...maybe there is an error within one of your files.
    Michael John Froseth
    Freelance Web Developer | MichaelFroseth | dotCom

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i am putting the include on the main index.html page but including a page in another directory like:

    <?php include('http://mysite.com/info/index.php'); ?>

    and puttin that on the index.html page for mysite.com



    [mysite.com = example site]

  6. #6
    SitePoint Zealot reinspire's Avatar
    Join Date
    Jun 2005
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My guess is that your webserver is not seeing the index.html as a PHP page.

    Try re-naming it to index.php

  7. #7
    SitePoint Zealot mike.fro's Avatar
    Join Date
    Jun 2005
    Location
    Lewisville, Texas
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php include("./path/to/your/file.html"); ?>
    Try that using the period before the slash. That might work.

    EDIT: I totally forgot about that. If you using the <?php include();?> function in a .html page...its not going to work. You'll always need a .php extension in any file you use PHP.
    Michael John Froseth
    Freelance Web Developer | MichaelFroseth | dotCom

  8. #8
    SitePoint Zealot reinspire's Avatar
    Join Date
    Jun 2005
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mike.fro
    EDIT: I totally forgot about that. If you using the <?php include();?> function in a .html page...its not going to work. You'll always need a .php extension in any file you use PHP.
    Well, unless through some means you have your web-server configured to handle .html files as PHP pages (depending on the server, this can be done if I'm not mistaken)

  9. #9
    SitePoint Zealot mike.fro's Avatar
    Join Date
    Jun 2005
    Location
    Lewisville, Texas
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by reinspire
    Well, unless through some means you have your web-server configured to handle .html files as PHP pages (depending on the server, this can be done if I'm not mistaken)
    Your right, it can. I doubt he has it set up that way though...maybe he does. We'll have to wait and see
    Michael John Froseth
    Freelance Web Developer | MichaelFroseth | dotCom

  10. #10
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you both!

    it worked, i had to rename my main file to index.php
    and then include this:

    <?php include('./filepath/index.php'); ?>

    i had to put the '.' before, thanks!




    ... now how can I css this and make the dimension right or overflow it? i cannot include an 'id' in that php, or can I? or would i have to just put a 'div' around the php?

  11. #11
    SitePoint Zealot reinspire's Avatar
    Join Date
    Jun 2005
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Xilica
    ...or would i have to just put a 'div' around the php?
    Yeah, do that!

    For CSS questions, head over to the CSS forum.

    http://www.sitepoint.com/forums/forumdisplay.php?f=53

  12. #12
    SitePoint Zealot mike.fro's Avatar
    Join Date
    Jun 2005
    Location
    Lewisville, Texas
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Not a problem, I figured that . before would help. Also the .php extension was really what you needed. Glad it worked!
    Michael John Froseth
    Freelance Web Developer | MichaelFroseth | dotCom

  13. #13
    SitePoint Evangelist sputza's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    528
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mike.fro
    PHP Code:
    <?php include("./path/to/your/file.html"); ?>
    Try that using the period before the slash. That might work.

    EDIT: I totally forgot about that. If you using the <?php include();?> function in a .html page...its not going to work. You'll always need a .php extension in any file you use PHP.
    I think the PHP5 standard is either .php .inc
    Although I have seen lots of websites now using both (whatever.inc.php)
    Steven Watkins
    Chief Web Ninja
    Code Monkey Interactive
    lowgravity.ca

  14. #14
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IIRC, you can include html pages just like a PHP page.

    Edit: Just tried it on my server-- worked fine.

  15. #15
    SitePoint Zealot mike.fro's Avatar
    Join Date
    Jun 2005
    Location
    Lewisville, Texas
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sputza
    I think the PHP5 standard is either .php .inc
    Although I have seen lots of websites now using both (whatever.inc.php)
    Yeah i've seen a lot of people using the.inc.php

    PHP Code:
    <?php include("./filepath/file.inc.php"); ?>
    I personally dont use it as much, i've started to use it a lot more though recently, since i'm building a CMS and it makes things easier for me.
    Michael John Froseth
    Freelance Web Developer | MichaelFroseth | dotCom


Bookmarks

Posting Permissions

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