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 5 of 5
  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts

    require and constants

    here's my init.php:
    PHP Code:
    <?php

    ob_start
    ();
    session_start();

    $hostname 'localhost';
    $database 'script';
    $username 'user';
    $password '';

    $err 'DB Problem';

    $connect mysql_connect($hostname$username$password);
    mysql_select_db($database) or die($err);

    define('ROOT', (dirname(__FILE__)));

    /*** Include the config file ***/
    if(!@require_once(dirname(__FILE__).'/config.php')) die('Can\'t find config.php');

    /*** Include the functions file ***/
    if(!@require_once $_SERVER['DOCUMENT_ROOT'] .'/includes/functions.php') die('Can\'t find functions.php');


    if(!@require_once 
    $_SERVER['DOCUMENT_ROOT'] .'/includes/template.func.php') die('Can\'t find template.func.php');;
    ?>
    here's config.php
    PHP Code:
    <?php 
    /********************************************

        IMG-ize Script 2012
        @version: 3.0
        
        @auth0or: Chris Reynolds
        
        Copyright 2012 Chris Reynolds
        
    ********************************************/

    $config['theme_folder_name']                    = 'MrOSX';

    $config['site_address']                            = 'http://www.thishosting.org'// No slash
    $config['site_path']                            = $_SERVER['DOCUMENT_ROOT'];
    $config['site_email']                            = 'webmaster@1domain.com';

    $config['upload_destination']                    = 'i293';
    $config['thumb_destination']                    = 'thumbs';

    $config['site_theme']                            = 'content/themes/MrOSX';
    $config['site_name']                            = 'ImgIze Script';
    $config['site_desc']                            = 'i293';


    ini_set("memory_limit","80M");

    $config['max_width']                            = 1900;
    $config['max_height']                            = 1900;
    $config['max_filesize']                            = 419304// Bytes only

    $config['multi_upload']                            = true// true or false
    $config['modules_enabled']                        = true// true or false
    $config['maintenance_mode']                        = false// true or false
    $config['facebook_comments']                    = true // true or false

    $config['facebook_app_id']                         = 'test'// Get your app id on http://developers.facebook.com/apps

    $config['acp_password']                         = 'password89';

    $config['allowed_mime_types']                    = array( 
                                                             
    'image/gif'
                                                             
    'image/jpeg'
                                                             
    'image/png'
                                                             
    'image/bmp' ); // allowed image types, to add more use: 'image{type}',

    ##################################################### DO NOT EIT BELOW... #####################################################

    define('THEME_DIR''content/themes/' $config['theme_folder_name'] .'/');
    define('CONTENT_DIR'$_SERVER['DOCUMENT_ROOT'] .'/content/');
    define('INCLUDES_DIR'$_SERVER['DOCUMENT_ROOT'] .'/includes/');

    ?>
    the constants aren't working now i've updated vars to constants, here's sme errors:

    Code:
    Warning: include_once(INCLUDES_DIRinit.php) [function.include-once]: failed to open stream: No such file or directory in /home/sonicimg/public_html/index.php on line 13
    
    Warning: include_once() [function.include]: Failed opening 'INCLUDES_DIRinit.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/sonicimg/public_html/index.php on line 13
    
    Warning: include(THEME_DIRindex.php) [function.include]: failed to open stream: No such file or directory in /home/sonicimg/public_html/index.php on line 15
    
    Warning: include() [function.include]: Failed opening 'THEME_DIRindex.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/sonicimg/public_html/index.php on line 15
    eg im calling stuff like this
    PHP Code:
        function include_themeHeader($theme) {
            include 
    THEME_DIR .'header.php';
        } 
    can ya help?
    Last edited by Chris-2k; 08-01-2012 at 03:28 PM.

  • #2
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    721
    Thanks
    20
    Thanked 84 Times in 84 Posts
    remove the $config bit?

    PHP Code:
    define('THEME_DIR''content/themes/' theme_folder_name .'/'); 

  • #3
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    721
    Thanks
    20
    Thanked 84 Times in 84 Posts
    ignore that i completley read your post wrong lol

  • #4
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Warning: include_once(INCLUDES_DIRinit.php)
    suggests that your include statement is incorrectly formed; you may have included unnecessary apostrophes:

    PHP Code:
    include_once(INCLUDES_DIR 'init.php'); 
    Otherwise, it's probably not pointing at the correct location (relative to the current file) - but my first suggestion is more probable.
    Last edited by AndrewGSW; 08-01-2012 at 07:54 PM.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Yes indeed. Problem is that this file has no been included as there is no replacement of the constant in use since it has not been treated as a string.
    Post the code in index.php.

    Edit:
    BTW, what are you doing with these ifs:
    Code:
    /*** Include the config file ***/
    if(!@require_once(dirname(__FILE__).'/config.php')) die('Can\'t find config.php');
    You cannot capture a fatal error and therefore cannot trigger a die (suppression will merely prevent it from displaying to the screen. It will still fatally die). I'll have to test when I get home, but I believe that include/require also only return a result on call if a return is provided from the main() of the included script.
    Last edited by Fou-Lu; 08-01-2012 at 07:56 PM.


  •  

    Posting Permissions

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