Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    May 2008
    Posts
    187
    Thanks
    7
    Thanked 7 Times in 7 Posts

    Serious PHP help needed. (constants and require_once)

    I have two webservers. One is apache, one is IIS. Configuration is the same, php is set up the same, source code is the same. Yet the Apache works, and the IIS does not. The apache one is my laptop, the development server, the IIS one is a crappy server that's the production server.

    The php web app is set up so every page has a require_once and it requires the config page. The config page defines all the constants for the web app, pretty much every page has to have it. And it works fine with apache. However, when this happens in IIS, it trys to include the file everytime throwing 30-40 notices that screws up the application and all kinds of other crap. However, if I check and see if the constants are defined already, and prevent them from being redefined, or turn off error reporting, I get nothing. As if the web app died. I'm stuck and I haven't the faintest clue what's going on. Does anyone else have an idea?

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,008
    Thanks
    2
    Thanked 311 Times in 303 Posts
    Post your code and at least the start of the errors for someone to have an idea what is going on and what the code is that corresponds to the errors.

    101 different people could write your first post here and each of them could have a different problem. The only way to get help with what is specifically happening in your code and with your errors is if you provide that information.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    Regular Coder
    Join Date
    May 2008
    Posts
    187
    Thanks
    7
    Thanked 7 Times in 7 Posts
    Here's the config file:
    PHP Code:
    <?php
    /**
     *    Contains the constants for the intranet
     *
     *    @package Intranet
     *    @subpackage Basic
     */
     
    //=============================================================================================
    //---------------------------------------------------------------------------------------------
    // General Configuration
    //---------------------------------------------------------------------------------------------
    //=============================================================================================

    //==========================
    //Directories
    //==========================
    // The URL to the root of the Resnet System.
    // Be sure to add the http:// but dont have a / at the very end.
    //define("ROOT", "http://157.89.4.59");
    define("ROOT""--");
    //define("ROOT", "http://127.0.0.1");

    //Intranets relitive URL
    define("INTRA_ROOT"ROOT);

    //Intranets absolute URL
    define("INTRA_ROOT_AB""C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\www");

    //location of the intranets include folder
    define("INTRA_INCLUDE"ROOT."/includes");

    //alias for INTRA_INCLUDE
    define("INTRA_INC"INTRA_INCLUDE);

    //location of the intranets include folder
    define("INTRA_INCLUDE_AB"INTRA_ROOT_AB."/includes");

    //alias
    define("INTRA_INC_AB"INTRA_INCLUDE_AB);

    //location of the intranets javascript folder
    define("INTRA_JS"ROOT."/js");

    //location of the intranets javascript folder
    define("INTRA_JS_AB"INTRA_ROOT_AB."/js");

    //location of the intranets css folder
    define("INTRA_CSS"ROOT."/css");

    //location of the intranets css folder
    define("INTRA_CSS_AB"INTRA_ROOT_AB."/css");

    //location of the intranets ajax folder
    define("INTRA_AJAX"INTRA_ROOT."/ajax");

    //location of the intranets ajax folder
    define("INTRA_AJAX_AB"INTRA_ROOT_AB."/ajax");

    //location of the intranets panes folder
    define("INTRA_PANES"ROOT."/panes");

    //location of the intranets panes folder
    define("INTRA_PANES_AB"INTRA_ROOT_AB."/panes");

    //location of the intranets image folder
    define("INTRA_IMAGE"ROOT."/images");

    //location of the intranets image folder
    define("INTRA_IMAGE_AB"INTRA_ROOT_AB."/images");


    //==========================
    //User Levels
    //==========================
    define("ADMIN"1);
    define("SHIFT_SUPERVISOR"2);
    define("TEAM_LEADER",3);
    define("STAFF"4);
    define("BANNED",5);

    //===========================================
    // MySQL Configuration
    //===========================================

    // The server/host the database connects to.
    // Can either be localhost, an IP, or a URL.
    define("MYSQL_SERVER","localhost");

    // The username used to access the database with.
    // The user should have the following privleges:
    // SELECT, INSERT, UPDATE, DELETE FROM
    define("MYSQL_USER""resnetadmin");

    // The password that goes along with the user.
    define("MYSQL_PASS","----");

    // The name of the database the tables are found in.
    define("MYSQL_DB","resnet");

    //=========================================
    // Attachments Config
    //=========================================

    // The folder where attachments are stored.
    define("INTRA_ATTR"ROOT "/attachments");
    define("INTRA_ATTR_AB"INTRA_ROOT_AB "/attachments");


    //=========================================
    // Login Config
    //=========================================
    // The number of seconds of inactivity until someone is logged out.
    define("LOGIN_TIMEOUT",600);

    //=========================================
    // Logger Config
    //=========================================
    //NOTICE: The Logger will have its own configuration in its class file.
    define("LOG_FILE"INTRA_INCLUDE_AB "/error_log.log");


    //==================================================
    //Configuration for the todo
    //==================================================
    define("WONT_DO"3);
    define("DONE"2);
    define("INPROGRESS"1);
    define("NOT_STARTED"0);

    //==================================================
    //Configuration for the timeoff
    //==================================================
    define("TIMEOFF_NOTHING"0);
    define("TIMEOFF_PENDING"1);
    define("TIMEOFF_APPROVED"2);
    define("TIMEOFF_DENIED"3);
    Here's the index that launches everything:
    PHP Code:
    <?php
        
    require_once("./includes/config.inc.php");
        require_once(
    INTRA_INCLUDE_AB."/Login.inc.php");
        require_once(
    INTRA_INCLUDE_AB."/page.inc.php");

        @
    session_start();
        
        
    $page = new Page();
        
    $login = new Login();
        
    $login->isLoggedIn();
        
    $login->isLoggedIn();
        
        echo 
    $page->buildHeader();
        
        if(
    $login->isLoggedIn()){    
            echo 
    $page->startPage();
            echo 
    $page->javascriptImports();
            echo 
    $page->loadLayout();
        }else{
            echo 
    '</head><body><div>
            <div id="errors">
            </div>'
    ;
            
            echo 
    $page->javascriptImports();
            
            echo 
    '<script type="text/javascript">
                $(document).ready(function(){
                    tb_show("Login", "ajax/login.php?height=90&amp;width=150&amp;modal=true");
                });
            </script>
            '
    ;        
        }
        
        echo 
    $page->endPage();
    ?>

  • #4
    Regular Coder
    Join Date
    May 2008
    Posts
    187
    Thanks
    7
    Thanked 7 Times in 7 Posts
    And here's page:
    PHP Code:
    <?php
    /**
     *    @package Intranet
     */
    /**
     * Just the configureations
     */
    require_once("config.inc.php");
    require_once(
    INTRA_INCLUDE_AB."/mysql.inc.php");
    require_once(
    INTRA_INCLUDE_AB."/structures.inc.php");
    /**
     *    Contains the methods for constructing and modifying a page
     *
     *    @package Intranet
     *    @subpackage Basic
     */
    class Page{
        private 
    $mysql;
        function 
    Page(){    
            
    //header("cache-control: must-revalidate"); 
            //header("Content-Encoding: gzip");
            //@ob_start("ob_gzhandler");
            
    $this->mysql = new mysql();
        }
        
        
    /**
         *    This method creates the pane and finds it based on the classpath and the class name.
         *
         *    CAUTION: Uses an Object Factory!
         *
         *     @param $div - the id for the pane
         */
        
    public function createPane($div){
            include_once(
    INTRA_PANES_AB."/".$div.".inc.php");
            
    $classname explode("_",$div);
            
    $classes = array();
            foreach(
    $classname as $class){
                
    $classes[] = ucfirst($class);
            }
            
    $classname = (implode($classes"_"));
            
            
    $object = new $classname();
            
    $tmp $object->getTitle();    //empty cannot read return values :(
            
    $title $tmp;
            if(
    $object->getTitle() == ""){
                
    $title $object->getId();
            }
            if(
    $tmp == '-1')
                
    $title "";
            
    $pane "\n<div class='pane'><dl class='sort'>";
            
    $pane .= $object->getBar();
            
    $pane .= "\t<dd><div class='$div'>";    
            
    $pane .= $object->output();
            
    $pane .= "\n\t</div></dd>\n</dl></div>";
            
            return 
    $pane;
        }
            
        
    /**
         *    Gets all the javascript files needed for the Intranet and returns them
         *
         *    @return string javascript imports
         */
        
    public function javascriptImports(){
            return 
    '
                <script type="text/javascript" src="'
    .INTRA_JS.'/jquery.js.php"></script>
                <script type="text/javascript" src="'
    .INTRA_JS.'/jquery-ui.js.php"></script>
                <script type="text/javascript" src="'
    .INTRA_JS.'/source/ui.datepicker.js.php"></script>
                <script type="text/javascript" src="'
    .INTRA_JS.'/thickbox/thickbox.js.php"></script>
                <script type="text/javascript" src="'
    .INTRA_JS.'/demo.js.php"></script>
                <script type="text/javascript" src="'
    .INTRA_JS.'/clockpick.js.php"></script>
                <script type="text/javascript" src="'
    .INTRA_JS.'/intranet.js.php"></script>
                <script type="text/javascript" src="'
    .INTRA_JS.'/md5.js.php"></script>';    //the md5 also has sha1
        
    }
        
        
    /**
         *    Creates the basic header for the intranet. Also includes the CSS
         *
         *    @param $title Sets the title for the page, default to RESNET, page never refreshes so this default never changes
         *    @todo Make the CSS use the constant to find the css folder -low priority
         */
        
    public function buildHeader($title "RESNET"){
            
    $html '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
                <head>
                <!-- Meta Data -->
                <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                <meta name="description" content="MAKE ME CHANGE THIS!" />
                <meta name="keywords" content="null" />
                <!-- Link to Style External Sheet -->
                <link href="' 
    INTRA_CSS '/main.css.php" type="text/css" rel="stylesheet" />
                <link href="' 
    INTRA_CSS '/panes.css.php" type="text/css" rel="stylesheet" />
                <link href="' 
    INTRA_CSS '/ui.datepicker.css.php" type="text/css" rel="stylesheet" />    
                <link href="' 
    INTRA_CSS '/demo.css.php" type="text/css" rel="stylesheet" />
                <link href="' 
    INTRA_CSS '/menuh.css.php" type="text/css" rel="stylesheet" />
                <link href="' 
    INTRA_CSS '/intramail.css.php" type="text/css" rel="stylesheet" />
                <link href="' 
    INTRA_CSS '/who.css.php" type="text/css" rel="stylesheet" />
                <link href="' 
    INTRA_CSS '/clockpick.css.php" type="text/css" rel="stylesheet" />
                <link href="'
    .INTRA_JS.'/thickbox/thickbox.css.php" type="text/css" rel="stylesheet" />
                <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> 
                <link rel="icon" href="' 
    INTRA_ROOT 'favicon.ico" type="image/x-icon" /> 
                
                <!--[if IE]>
                <style type="text/css" media="screen">
                 #menu ul li {float: left; width: 100%;}
                </style>
                <![endif]-->
                <!--[if lt IE 7]>
                <style type="text/css" media="screen">
                body {
                behavior: url(csshover.htc);
                font-size: 100%;
                }

                #menu ul li a {height: 1%;
    z-index: 500;} 

                #menu a, #menu h2 {
                font: bold 0.7em/1.4em arial, helvetica, sans-serif;
                }
                </style>
                <![endif]-->
                            
                <!-- Site Title -->
                <title>'
    .$title.'</title>';
            return 
    $html;
        }
        
        
    /**
         *    The start of the actual page. Body is opened here and head is closed. The header of the page is created. All the menu items for the drop down bar is here
         */
        
    public function startPage(){
            
    $html "\n</head>
                    <body>
                    <div id='page'>
                        <div id='header'>
                            <span id='logo'>
                                <a onclick='logoClick()' style='cursor: default' ><img src='./images/ResNetIntranet.gif' alt='logo' height='95' /></a>
                            </span>
                            <span class='right'>                            
                                Welcome back "
    .ucfirst($_SESSION['username'])."! Today is ".date('D, F j, Y').".<br />
                                <br />
                                Search: <input id='search' type='text' disabled='disabled' />
                            </span>
                        </div>
                        <div id='nav_header'>
                            <div class='left'>"
    ;
                        
    $html .= '
        <div id="menu">
    <ul>
      <li><h2><a href=".">Home</a></h2>
      </li>
    </ul>

    <ul>
      <li><h2>Add Content</h2>
        <ul>
            <li><h3>Left Column</h3>
                <ul>
                    <li><a onclick="addPane(\'avatar_pane\', \'left_pane\', \''
    .INTRA_AJAX.'\')">Avatar</a></li>
                    <li><a onclick="addPane(\'admin_link_pane\', \'left_pane\', \''
    .INTRA_AJAX.'\')">Controls</a></li>
                    <li><a onclick="addPane(\'intramail_info_pane\', \'left_pane\', \''
    .INTRA_AJAX.'\')">Intramail</a></li>
                    <li><a onclick="addPane(\'meetings_today_pane\', \'left_pane\', \''
    .INTRA_AJAX.'\')">Meetings</a></li>
                    <li><a onclick="addPane(\'myhr_pane\', \'left_pane\', \''
    .INTRA_AJAX.'\')">MyHR</a></li>
                    <li><a onclick="addPane(\'who_pane\', \'left_pane\', \''
    .INTRA_AJAX.'\')">Who</a></li>
                </ul>
            </li>
            <li><h3>Right Column</h3>
                <ul>
                    <li><a onclick="addPane(\'avatar_pane\', \'right_pane\', \''
    .INTRA_AJAX.'\')">Avatar</a></li>
                    <li><a onclick="addPane(\'admin_link_pane\', \'right_pane\', \''
    .INTRA_AJAX.'\')">Controls</a></li>
                    <li><a onclick="addPane(\'intramail_info_pane\', \'right_pane\', \''
    .INTRA_AJAX.'\')">Intramail</a></li>
                    <li><a onclick="addPane(\'meetings_today_pane\', \'right_pane\', \''
    .INTRA_AJAX.'\')">Meetings</a></li>
                    <li><a onclick="addPane(\'myhr_pane\', \'right_pane\', \''
    .INTRA_AJAX.'\')">MyHR</a></li>
                    <li><a onclick="addPane(\'who_pane\', \'right_pane\', \''
    .INTRA_AJAX.'\')">Who</a></li>
                </ul>
            </li>
            <li><h3><a onclick="resetLayout()">Reset</a></h3></li>
        </ul>
      </li>
    </ul>

    <ul>
      <li><h2>Places</h2>
                <ul>
                    <li><a>Projects</a></li>
                    <li><a>Reports</a></li>
                    <li><a>Take a Break</a></li>    
                </ul>
            </li>
    </ul>                            
    </div>'
    ;
                            
    $html .= '</div>
                            <div class="right">'
    ;
                            if(
    $_SESSION['level'] == ADMIN)
                                
    $html .= '<a href="' ROOT '/phpmyadmin/index.php?db=resnet">PhpMyAdmin</a> |';
                            
    $html .='<a href="' ROOT '/doc/">Documentation</a>&nbsp;|
                                <a href="' 
    ROOT '/codetrack">Bugs</a>&nbsp;|&nbsp;<a onclick="$.post(\'../ajax/logout.php\', function(data){
                                    $(\'.main_pane\').append(data);
                                })">Logout</a>
                            </div>
                        </div>
                        '
    ;
            return 
    $html;
        }
        
        
    /**
         *    Shuts down the page, closes the page div and body and html.
         */
        
    public function endPage(){
            
    $html="</div>
                </body>
                </html>"
    ;
            return 
    $html;
        }
        
        
    /**
         *    Resest the layout to the default layout which can be found in the javascript function loadDefault in intranet.js
         */
        
    public function defaultLayout(){
            return 
    "<div id='left_pane'>
                    </div>
                    <div id='center_pane'>
                    </div>
                    <div id='right_pane'>
                    </div>
                    <script type='text/javascript'>
                        setTimeout(function(){
                            loadDefault('"
    .INTRA_AJAX."');
                        }, 100);
                    </script>"
    ;
        }
        
        
    /**
         *    Grabs the layout from the database and outputs it to the page.
         *    Fixed so it doesn't check for the center column which never changes
         */
        
    public function loadLayout(){
            
    $panes = array();
        
            
    $sql "SELECT * FROM panes WHERE userId = ".$_SESSION['id'];
            
    $result $this->mysql->query($sql);    //it's safe
            
            //if there are no boxes, can only happen with the user is newly created
            //there are boxes that cannot be deleted (or added).
            
    if(mysql_num_rows($result) < 1)
                return 
    $this->defaultLayout();
            
            while(
    $row mysql_fetch_array($result)){
                
    $panes[] = new SimplePane($row['pane'], $row['x'], $row['y']);
            }
                    
            
    //do layout, start with left column
            
    $html "<div id='left_pane'>";
            foreach(
    $panes as $p){
                if(
    $p->== 0)
                    
    $html .= $this->createPane($p->id);
            }
            
    $html .="</div><div id='center_pane'>";
            
    //always the same
                
    $html .=$this->createPane('fyi_pane');
                
    $html .=$this->createPane('title_pane');
                
    $html .=$this->createPane('main_pane');
            
    $html .="</div><div id='right_pane'>";
            foreach(
    $panes as $p){
                if(
    $p->== 2)
                    
    $html .= $this->createPane($p->id);
            }
            
    $html .="</div>";
            
            return 
    $html;
        }
        
    }
    ?>
    The warnings are:
    Notice: Constant ROOT already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 25

    Notice: Constant INTRA_ROOT already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 28

    Notice: Constant INTRA_ROOT_AB already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 31

    Notice: Constant INTRA_INCLUDE already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 34

    Notice: Constant INTRA_INC already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 37

    Notice: Constant INTRA_INCLUDE_AB already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 40

    Notice: Constant INTRA_INC_AB already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 43

    Notice: Constant INTRA_JS already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 46

    Notice: Constant INTRA_JS_AB already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 49

    Notice: Constant INTRA_CSS already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 52

    Notice: Constant INTRA_CSS_AB already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 55

    Notice: Constant INTRA_AJAX already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 58

    Notice: Constant INTRA_AJAX_AB already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 61

    Notice: Constant INTRA_PANES already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 64

    Notice: Constant INTRA_PANES_AB already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 67

    Notice: Constant INTRA_IMAGE already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 70

    Notice: Constant INTRA_IMAGE_AB already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 73

    Notice: Constant ADMIN already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 79

    Notice: Constant SHIFT_SUPERVISOR already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 80

    Notice: Constant TEAM_LEADER already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 81

    Notice: Constant STAFF already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 82

    Notice: Constant BANNED already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 83

    Notice: Constant MYSQL_SERVER already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 91

    Notice: Constant MYSQL_USER already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 96

    Notice: Constant MYSQL_PASS already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 99

    Notice: Constant MYSQL_DB already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 102

    Notice: Constant INTRA_ATTR already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 109

    Notice: Constant INTRA_ATTR_AB already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 110

    Notice: Constant ATTR_MAX_SIZE already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 111

    Notice: Constant ATTR_ALLOWED already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 112

    Notice: Constant LOGIN_TIMEOUT already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 118

    Notice: Constant LOG_FILE already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 124

    Notice: Constant WONT_DO already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 130

    Notice: Constant DONE already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 131

    Notice: Constant INPROGRESS already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 132

    Notice: Constant NOT_STARTED already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 133

    Notice: Constant TIMEOFF_NOTHING already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 138

    Notice: Constant TIMEOFF_PENDING already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 139

    Notice: Constant TIMEOFF_APPROVED already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 140

    Notice: Constant TIMEOFF_DENIED already defined in \\resnetweb\resnet\youlikethat\includes\config.inc.php on line 141

  • #5
    Regular Coder
    Join Date
    May 2008
    Location
    Ohio
    Posts
    231
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Make sure that all of your files are using require_once - not just the ones you posted.
    zok@zoklet:~$ whereis zok
    zok: http://zoklet.net | http://zoklet.net/otg | /derzok/at/gmail/dot/com

  • #6
    Regular Coder
    Join Date
    May 2008
    Posts
    187
    Thanks
    7
    Thanked 7 Times in 7 Posts
    They are, I think the problem is that some of them uses different relative paths, and IIS isn't smart enough to figure it out.

  • #7
    Regular Coder
    Join Date
    May 2008
    Location
    Ohio
    Posts
    231
    Thanks
    3
    Thanked 21 Times in 21 Posts
    That would have been my second guess. I know it might be inefficient to do this, but a quick fix is: use the defined() function to check if each constant is defined before defining it - kind of like C's #ifndef directive.
    zok@zoklet:~$ whereis zok
    zok: http://zoklet.net | http://zoklet.net/otg | /derzok/at/gmail/dot/com

  • #8
    Regular Coder
    Join Date
    May 2008
    Posts
    187
    Thanks
    7
    Thanked 7 Times in 7 Posts
    yeah, when I do that, nothing happened. It's almost working now. For some reason, almost every single request returns a 404. I don't know what's causing it.

  • #9
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,008
    Thanks
    2
    Thanked 311 Times in 303 Posts
    You are including the config.inc.php file twice.

    require_once("config.inc.php"); and require_once("./includes/config.inc.php"); are completely different files as far as require_once() is concerned (php.net has a poor history of getting the logic for require/include to work.)

    You need to organize your code so that it only includes your configuration file in one place, at the start of the main script.

    If you must do your code that way it currently is, then form an absolute file system path to use everywhere you include/require the file -

    PHP Code:
    require_once($_SERVER['DOCUMENT_ROOT'] . "/includes/config.inc.php"); 
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #10
    Regular Coder
    Join Date
    May 2008
    Posts
    187
    Thanks
    7
    Thanked 7 Times in 7 Posts
    Yeah, I just said that :P Thanks for helping though. The problem was that Apache can figure it out, and doesn't include the file twice, but IIS does not and it includes it twice causing such error. The webapp isn't suited for the $_SERVER['DOCUMENT_ROOT'] because the includes folder can be anywhere (why someone would do that, I don't know), so I just added the path to php's include_path.


  •  

    Posting Permissions

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