SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    require() problem

    poll.php:

    Code:
    <?php
    
    require( "includes/common.php" );
    
    ?>
    includes/common.php:

    Code:
    <?php
    $INFO = array();
    $INFO['document_root'] = '/usr/www/heavend1/httpd/htdocs/wildfire/0ad/new_site/';
    
    require( $INFO['document_root']."includes/functions.php" );
    ?>
    includes/functions.php:
    Code:
    <?php
    
    echo "funcs loaded";
    ?>
    Now when I access poll.php through http then I see a blank page instead of the "funcs loaded" caption. Seems the functions.php doesn't get loaded although the document root is correct. Any ideas ?

  2. #2
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and by the way the parser doesn't throw any errors at me either.

  3. #3
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try inserting a few more echo's:

    PHP Code:
    <?php
    error_reporting
    (E_ALL);

    echo 
    'About to include includes/common.php';
    require( 
    "includes/common.php" );
    echo 
    'Included includes/common.php';
    ?>
    includes/common.php:

    PHP Code:
    <?php
    echo 'includes/common.php successfully included';
    $INFO = array();
    $INFO['document_root'] = '/usr/www/heavend1/httpd/htdocs/wildfire/0ad/new_site/';

    echo 
    'about to include ' $INFO['document_root']."includes/functions.php";
    require( 
    $INFO['document_root']."includes/functions.php" );
    echo 
    'included ' $INFO['document_root']."includes/functions.php";
    ?>
    includes/functions.php:
    PHP Code:
    <?php
    echo "funcs loaded (i.e. includes/functions.php succeesfully included)";
    ?>
    My name is Steve, and I'm a super-villian.

  4. #4
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the whole poll.php:

    PHP Code:
    <?php
    error_reporting
    (E_ALL);

    define('IN_SCRIPT'true);

    echo 
    "About to includhhhhhhhhhhhhhe includes/common.php";
    // require( "includes/common.php" );
    echo 'Included includes/common.php'

    class test
    {
        var 
    $poll_html;

        function 
    test()
        {
            global 
    $std_func;

            
    $this->poll_html $std_func->load_template('skin_poll');
            
    $edit_link   $this->poll_html->edit_link();
            echo 
    $edit_link;
        }
    }

    $obj = new test;

    ?>
    Not even now there is any output ! I am frightened. :S

  5. #5
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php

    // error_reporting(E_ALL);

    // define('IN_SCRIPT', true);

    echo "hello world3";
    require(
    'common.php');


    /*
    class test
    {
        var $poll_html;

        function test()
        {
            global $std_func;

            $this->poll_html = $std_func->load_template('skin_poll');
            $edit_link   = $this->poll_html->edit_link();
            echo $edit_link;
        }
    }

    $obj = new test;
    */

    ?>
    AT least good old hello world works now. Now I copied common.php into the same dir where poll.php is, but still it won't load it with require('common.php') . I even put syntax errors into common.php, but I get no parse error so it's definately not loaded. *sigh*

  6. #6
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay got it now that it loads database.php and conf_global.php (yes made a separate file again) with the dirname(__FILE__) function.

    require( dirname(__FILE__)."/conf_global.php" );
    require( dirname(__FILE__)."/functions.php" );
    require( dirname(__FILE__)."/database.php" );

    For some very odd reason, it doesn't load functions.php though, nor does it throw an error. Weird. Any idea ?

    Code of functions.php:

    PHP Code:
    <?php

    /*
    +--------------------------------------------------------------------------
    |   Project 0AD Website/Intranet
    |   ========================================
    |   by Tim [DarkAngelBGE] Koschuetzki
    |   ========================================
    |   Email: [email]DarkAngelBGE@aol.com[/email]
    +---------------------------------------------------------------------------
    |
    |   > common functions module
    |   > Module written by Tim Koschuetzki
    |   > Date started: 10th September 2003
    |
    |        > Module Version Number: 1.0.0
    +--------------------------------------------------------------------------
    */


    echo "<br />funcs loaded";

    //-------------------------------------------
    // class to hold standard functions
    //-------------------------------------------

    class std_functions
    {
    ...

  7. #7
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Throwing an extra buiscuit in:

    Check the output of this script here: http://wildfiregames.com/0ad/new_site/poll.php



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
  •