cardwell164 Posted May 19, 2014 Share Posted May 19, 2014 Hello! First of all, i would like to thank everyone in this community as this is where i post most of the problems that i can no longer fix on my own. and everytime i do, i get all the help i need and with a 100% success rate. Anyway, i am following a tutorial, however the tutorial is based on a MAC environment and i am working on windows. I think this is a problem with the DIRECTORY_SEPARATOR but i might be wrong. I am getting this error message "Notice: Use of undefined constant LIB_PATH - assumed 'LIB_PATH' in C:\wamp\www\beyond_basics_photogallery\includes\database.php on line 2" i will just post the code that is relevant to this error. here is the code for database.php: (config.php is in the same folder with database.php) require_once(LIB_PATH.DS."config.php"); and this is my initialize.php where i initialized my DIRECTORY_SEPARATOR. this is also located in the same folder with database.php <?php // Define the core paths // Define them as absolute paths to make sure that require_once works as expected defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('SITE_ROOT') ? null : define('SITE_ROOT', DS.'wamp'.DS.'www'.DS.'beyond_basics_photogallery'); defined('LIB_PATH') ? null : define('LIB_PATH', SITE_ROOT.DS.'includes'); // load config file first require_once(LIB_PATH.DS.'config.php'); // load basic functions next so that everything after can use them require_once(LIB_PATH.DS.'functions.php'); // load core objects require_once(LIB_PATH.DS.'session.php'); require_once(LIB_PATH.DS.'database.php'); // load database-related classes require_once(LIB_PATH.DS.'user.php'); ?> and this is the path to my project folder: C:\wamp\www\beyond_basics_photogallery I have tried everything i could but i am completely lost as to what is causing this. could it be the SITE_ROOT statement? i appreciate any help. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/288592-problem-with-notice-use-of-undefined-constant/ Share on other sites More sharing options...
bsmither Posted May 19, 2014 Share Posted May 19, 2014 (edited) I am not at all sure the ternary format is conducive to making statements (sorry, I don't have the terminology to name this type of statement). As best I know, the ternary format is supposed to return a value from two expressions, one for true and one for false, and assign it to a variable, or to use it 'in-line'. So, this, define('DS', DIRECTORY_SEPARATOR), doesn't evaluate to anything. It certainly does something, but is doing something in this context the same as making a result available for use. (I've seen some weird statement formulations, especially with the for() parameters, so this may be perfectly legitimate.) But I have my doubts. So, I would experiment with: if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR); Edited May 19, 2014 by bsmither Quote Link to comment https://forums.phpfreaks.com/topic/288592-problem-with-notice-use-of-undefined-constant/#findComment-1480013 Share on other sites More sharing options...
QuickOldCar Posted May 19, 2014 Share Posted May 19, 2014 Use the $_SERVER variables for setting your paths http://us1.php.net/manual/en/reserved.variables.server.php Quote Link to comment https://forums.phpfreaks.com/topic/288592-problem-with-notice-use-of-undefined-constant/#findComment-1480014 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.