Announcement

Collapse
No announcement yet.

global.php - how to include?`

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • global.php - how to include?`

    Hi all, quick question regarding global.php

    How do you include it corrently within a file that isnt in the same directory.

    i.e

    Home
    |_____ Forums
    |_____ SomeFolder

    When I try to include the global.php file when in the 'SomeFolder' folder it kicks out the error:

    Fatal error: Failed opening required './includes/init.php' (include_path='.:/usr/local/lib/php') in /usr/local/apache-82/htdocs/forums/global.php on line 18

    Is there a correct way to include it such that global.php can then include its required files correctly.

    I want to keep my code changes in seperate folders but this little niggle is preventing me from doing so.

    Any help guys?
    Taz
    http://www.e-tones.co.uk - The best site on the net for mobile phones.

  • #2
    Easy:

    PHP Code:
    <?php
     
    chdir
    ('/path/to/vbulletin/files');
    require_once(
    './global.php');
     
    // do stuff
     
    ?>

    Comment


    • #3
      Or in your case...

      PHP Code:
      <?php
       
      // this file is located in Home/SomeFolder
       
      chdir('../Forums');
      require_once(
      './global.php');
       
      // do stuff
       
      ?>

      Comment


      • #4
        Originally posted by Kier
        Easy:

        PHP Code:
        <?php
         
        chdir
        ('/path/to/vbulletin/files');
        require_once(
        './global.php');
         
        // do stuff
         
        ?>
        why thankyou lord kier

        Much appreciated

        Taz
        http://www.e-tones.co.uk - The best site on the net for mobile phones.

        Comment


        • #5
          ekk.. it works perfecty, but images etc stored in the vb arrays ($stylevar etc) obviously now no longer point to the right location... any easy work around?

          Taz
          Last edited by etones; Mon 22 Dec '03, 7:45am.
          http://www.e-tones.co.uk - The best site on the net for mobile phones.

          Comment


          • #6
            No problem

            Comment


            • #7
              any ideas to the image location problem?

              Taz
              http://www.e-tones.co.uk - The best site on the net for mobile phones.

              Comment


              • #8
                Yeah - switch all your image paths to be absolute.

                For example, if you have this arrangement:

                www.mysite.com
                -- forums
                ---- images

                And you are used to specifying the path to an image as "images/myimage.gif", you would need to change the path to "/forums/images/myimage.gif". Do this for all the image paths in the stylevars editor and it will work fine.

                Comment


                • #9
                  Originally posted by Kier
                  Yeah - switch all your image paths to be absolute.

                  For example, if you have this arrangement:

                  www.mysite.com
                  -- forums
                  ---- images

                  And you are used to specifying the path to an image as "images/myimage.gif", you would need to change the path to "/forums/images/myimage.gif". Do this for all the image paths in the stylevars editor and it will work fine.
                  excellent. Will give it a go. Cheers
                  http://www.e-tones.co.uk - The best site on the net for mobile phones.

                  Comment


                  • #10
                    Originally posted by etones
                    excellent. Will give it a go. Cheers
                    works like a charm... who'd have guessed

                    Thanks kier

                    Taz
                    http://www.e-tones.co.uk - The best site on the net for mobile phones.

                    Comment


                    • #11
                      Originally posted by Kier
                      Yeah - switch all your image paths to be absolute.

                      For example, if you have this arrangement:

                      www.mysite.com
                      -- forums
                      ---- images

                      And you are used to specifying the path to an image as "images/myimage.gif", you would need to change the path to "/forums/images/myimage.gif". Do this for all the image paths in the stylevars editor and it will work fine.
                      Hi Kier, this has lead to some more problems. I have to do the same for EVERY link in the software, is there an easier way?

                      Please help,
                      Taz
                      http://www.e-tones.co.uk - The best site on the net for mobile phones.

                      Comment


                      • #12
                        By the way, the reason why you have to change the directory (chdir) is, because global.php itself references files inside the vB folder structure (some ./includes, etc.).

                        I just added this for you to *understand* why things have to be done, not only how. ;-)

                        Regards
                        Ralf

                        Comment


                        • #13
                          Originally posted by rrottman
                          By the way, the reason why you have to change the directory (chdir) is, because global.php itself references files inside the vB folder structure (some ./includes, etc.).

                          I just added this for you to *understand* why things have to be done, not only how. ;-)

                          Regards
                          Ralf
                          I understand the reason, however im looking for a simple work around (i.e is there a setting in the software that i've missed etc).

                          Taz
                          http://www.e-tones.co.uk - The best site on the net for mobile phones.

                          Comment


                          • #14
                            A workaround for what? You want PHP to find the include files without the need to changedir? I guess you then have to consult your php.ini if you're not on a shared hosting plan.

                            Comment


                            • #15
                              Thanks for that bit of info kier.

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...
                              X