Include command, PHP

Discussion in 'Computer Support' started by Steve Freides, Jan 18, 2004.

  1. I asked yesterday about including another web page in several of my pages as
    part of a redirection process. I wasn't clear - I know how to handle the
    redirection already.

    My ISP tells me they support php. Could some please provide an example of
    an include? In my case, I want page

    http://www.domain_name.com/page_1.htm

    to include

    http://www.domain_name.com/include_page.htm

    I actually do not need to include a web page - it's a block of text I need
    to include. Whatever will get me there will suffice. The included block of
    text will be the only visible item on page_1.htm and others like it.

    Hope I've explained better, and TIA.

    -S-
     
    Steve Freides, Jan 18, 2004
    #1
    1. Advertisements

  2. Steve Freides

    why? Guest

    Do you really need to include the text for a redirection?
    If your ISPs webserver is Apache you can use the mod_rewrite

    This means any request like this (only 1 example)
    www.myservername/site
    is transparently changed to
    www.myservername/newsite

    or even
    www.servername/site/index.html
    can become
    www.servername/site/indexywar2003.html
    www.servername/site/indexywar2004.html
    as needed, this way visitors to the site only need know about 1 URL.

    http://httpd.apache.org/docs/mod/mod_rewrite.html
    Maybe include a file is what you mean?

    http://www.php-include.com/
    http://www.w3schools.com/php/
    http://www.bigwebmaster.com/PHP/Tutorials/

    PHP newsgroups
    http://news.php.net/

    Find closest mirror for the documentation, tutorial , user groups
    http://uk2.php.net/sites.php

    <snip>

    Me
     
    why?, Jan 18, 2004
    #2
    1. Advertisements

  3. Steve Freides

    °Mike° Guest

    °Mike°, Jan 18, 2004
    #3
  4. Hywel Jenkins, Jan 18, 2004
    #4
  5. I looked at the link you provided, and added

    <?php
    include "pagename.htm"
    ?>

    into the body section of my page - it doesn't display. Using a fully
    qualified URL didn't help, neither did moving it above the start of the body
    section.

    Any ideas as to what I'm doing wrong? It doesn't give errors, just doesn't
    work.

    -S-
     
    Steve Freides, Jan 18, 2004
    #5
  6. Steve Freides

    °Mike° Guest

    Did your read this part?

    "Be sure to have an appropriate include_path setting as well."

    http://uk.php.net/manual/en/configuration.directives.php#ini.include-path

    include_path string

    Specifies a list of directories where the require(), include() and
    fopen_with_path() functions look for files. The format is like the
    system's PATH environment variable: a list of directories separated with
    a colon in Unix or semicolon in Windows.

    Example 4-3. Unix include_path
    include_path=".:/php/includes"

    Example 4-4. Windows include_path
    include_path=".;c:\php\includes"

    Using a . in the include path allows for relative includes as it means
    the current directory.


     
    °Mike°, Jan 18, 2004
    #6
  7. Is your server properly configured? Have you named the file correctly?
    What's in the source code when you view the page from your browser?
    URL?
     
    Hywel Jenkins, Jan 18, 2004
    #7
  8. So, since the file is kept in the same place, and the server runs some
    flavor of *nix,

    ?php
    include_path="."
    include "pagename.htm"
    ?>

    should make it work? I notice that the "=" isn't shown in all the examples,
    e.g., the heading just says include_path string.

    -S-

     
    Steve Freides, Jan 18, 2004
    #8
  9. Steve Freides

    °Mike° Guest

    I'm not versed in php -- I'm just trying to point you in
    the right direction. I suggest you start reading; you
    missed the obvious from my first post.


     
    °Mike°, Jan 18, 2004
    #9
  10. With all due respect, Mike, I _did_ read, I'm not convinced that
    include_path is even necessary if the file to be included is in the same
    folder, and I would like to hear from someone who is familiar with php
    rather than someone who can perform a Google search. I'm perfectly capable
    of that myself.

    -S-
    http://www.kbnj.com


     
    Steve Freides, Jan 18, 2004
    #10
  11. Is your server properly configured? Have you named the file correctly?
    What's in the source code when you view the page from your browser?
    URL?

    My ISP and web hosting provider is Earthlink. They tell me they run Unix
    and support php. The source code, when viewed from a browser, is just as it
    was when I composed it. I'm using MS Front Page and working with the HTML
    directly. Here's the page - have a look for yourself - it times out in 5
    seconds now but that's enough time to open up the source code window.

    http://www.kbnj.com/bpa.htm

    -S-
    http://www.kbnj.com
     
    Steve Freides, Jan 18, 2004
    #11
  12. Steve Freides

    °Mike° Guest

    Obviously you're not, else you would have sorted your
    problem out by now. There are many webmaster
    forums out there, or even newsgroups. Try them.


    <snip>
     
    °Mike°, Jan 18, 2004
    #12
  13. Lose the include_path line, too, it shouldn't be in there, but should be
    your php.ini file - you won't be able to edit that.
     
    Hywel Jenkins, Jan 18, 2004
    #13
  14. Steve Freides

    why? Guest

    That's lucky then, I have seen FP alter/mangle HTML/scripting codes not
    generated by itself.
    Have you tried any more basic PHP like any of this?

    <? print ("Hello World"); ?>

    <? print date("H:i:s"); ?>

    or with HTML

    <body>
    <b>
    <?php
    print "Hello World";
    ?>
    </b>
    </body>

    Me
     
    why?, Jan 18, 2004
    #14
  15. Tried some simple php, nothing appeared on the screen, so I'll be calling
    the ISP's tech support tomorrow morning. I'll report back on what I find.

    Any chance that my IE 6 has a setting that doesn't allow php by default?

    -S-
    http://www.kbnj.com
     
    Steve Freides, Jan 18, 2004
    #15
  16. Nope - PHP Commands are executed by the server, not the client. (GOHD!
    Can you imagine extra PHP commands for IE pre-5.5sp1, IE 5.5sp1, IE
    5.5sp2, IE 6.x, Mozilla pre-1.x, Mozilla 1.0, Mozilla 1.1 - 1.4, Mozilla
    1.5 + 1.6......)
     
    BuffNET Tech Support - MichaelJ, Jan 19, 2004
    #16
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.