Help with paths

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jpb

    Help with paths

    I have been using SSI would like to start using php

    From what I have seen php does not support absolute paths like SSI
    eg
    <!--#include virtual="/inc/css-gateway.inc" -->
    will work: but

    <? include("/inc/css-gateway.inc") ?>



    Warning: main(/inc/css-gateway.inc) [function.main]: failed to create
    stream: No such file or directory in
    /home/jpb/public_html/www/de/immobilien/main.php on line 15

    Fatal error: main() [function.main]: Failed opening required
    '/inc/css-gateway.inc' (include_path=' .:/usr/share/php') in
    /home/jpb/public_html/www/de/immobilien/main.php on line 15

    <? include("../../inc/css-gateway.inc") ?>
    this works as intended.


    Is there any way of declaring the server "/" and using absolute path?

    Paul




  • Kevin Thorpe

    #2
    Re: Help with paths

    jpb wrote:[color=blue]
    > I have been using SSI would like to start using php
    >
    > From what I have seen php does not support absolute paths like SSI
    > eg
    > <!--#include virtual="/inc/css-gateway.inc" -->
    > will work: but
    >
    > <? include("/inc/css-gateway.inc") ?>[/color]

    try
    <?php include("$_SERV ER[DOCUMENT_ROOT]/inc/css-gateway.inc"); ?>


    Comment

    • John Downey

      #3
      Re: Help with paths

      jpb wrote:[color=blue]
      > I have been using SSI would like to start using php
      >
      > From what I have seen php does not support absolute paths like SSI
      > eg
      > <!--#include virtual="/inc/css-gateway.inc" -->
      > will work: but
      >
      > <? include("/inc/css-gateway.inc") ?>
      >
      >
      >
      > Warning: main(/inc/css-gateway.inc) [function.main]: failed to create
      > stream: No such file or directory in
      > /home/jpb/public_html/www/de/immobilien/main.php on line 15
      >
      > Fatal error: main() [function.main]: Failed opening required
      > '/inc/css-gateway.inc' (include_path=' .:/usr/share/php') in
      > /home/jpb/public_html/www/de/immobilien/main.php on line 15
      >
      > <? include("../../inc/css-gateway.inc") ?>
      > this works as intended.
      >
      >
      > Is there any way of declaring the server "/" and using absolute path?
      >
      > Paul
      >
      >
      >
      >[/color]
      Since SSI was designed to be used from inside Apache it takes the root
      of the system to be your webroot. PHP is not so limited it will always
      think your system root is / or C:\ on windows. I don't know of any way
      to change this action.

      --
      John Downey




      Comment

      • jpb

        #4
        Re: Help with paths

        On Fri, 24 Oct 2003 13:16:27 +0100, Kevin Thorpe wrote:
        [color=blue]
        > jpb wrote:[color=green]
        >> I have been using SSI would like to start using php
        >>
        >> From what I have seen php does not support absolute paths like SSI eg
        >> <!--#include virtual="/inc/css-gateway.inc" -->
        >> will work: but
        >>
        >> <? include("/inc/css-gateway.inc") ?>[/color]
        >
        > try
        > <?php include("$_SERV ER[DOCUMENT_ROOT]/inc/css-gateway.inc"); ?>[/color]

        Thank you

        It seems to work.

        Paul

        Comment

        • jpb

          #5
          Re: Help with paths

          On Fri, 24 Oct 2003 14:26:53 +0200, jpb wrote:
          [color=blue]
          > On Fri, 24 Oct 2003 13:16:27 +0100, Kevin Thorpe wrote:
          >[color=green]
          >> jpb wrote:[color=darkred]
          >>> I have been using SSI would like to start using php
          >>>
          >>> From what I have seen php does not support absolute paths like SSI eg
          >>> <!--#include virtual="/inc/css-gateway.inc" -->
          >>> will work: but
          >>>
          >>> <? include("/inc/css-gateway.inc") ?>[/color]
          >>
          >> try
          >> <?php include("$_SERV ER[DOCUMENT_ROOT]/inc/css-gateway.inc"); ?>[/color]
          >
          > Thank you
          >
          > It seems to work.
          >
          > Paul[/color]

          Well that was a short lived " I finally got something working"

          On my Linux box:
          echo $_SERVER[DOCUMENT_ROOT] ->/home/jpb/public_html/www and it works;
          but on the server
          echo $_SERVER[DOCUMENT_ROOT] ->/usr/local/apache/htdocs

          the error log complain with the following

          [Fri Oct 24 10:38:07 2003] [error] PHP Warning:
          main(/usr/local/apache/htdocs/inc/css-gateway.inc): failed to open stream:
          No such file or directory in
          /mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15

          [Fri Oct 24 10:38:07 2003] [error] PHP Warning: main(): Failed opening
          '/usr/local/apache/htdocs/inc/css-gateway.inc' for inclusion
          (include_path=' .:/usr/local/lib/php') in
          /mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15


          So I guess it's back to the old SSI.

          Paul

          Comment

          Working...