Jump to content

problem with "Notice: Use of undefined constant"


cardwell164

Recommended Posts

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!

 

 

Link to comment
Share on other sites

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 by bsmither
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.