Use of undefined constant

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
a2once
Forum Newbie
Posts: 4
Joined: Sun Jun 29, 2008 1:07 pm

Use of undefined constant

Post by a2once »

Hello,

Can anyone please help with my problem in php, well i don't understand why am receiving this error, although
the script is running. but this error is there on the top of my page.. check this..

Use of undefined constant FoundModule - assumed 'FoundModule'
Notice: Use of undefined constant INCLUDE_PATH - assumed 'INCLUDE_PATH'

this is the script..

<?
require_once ("set.config.php");
require_once ("Application.php");
require_once ("Autoexec.php");

$db = mysql_pconnect(DB_HOST, DB_USER, DB_PASS) or trigger_error(mysql_error(),E_USER_ERROR);

# Select Database
mysql_select_db(DB_NAME, $db);

$_SERVER['REQUEST_URI'] = strtolower($_SERVER['REQUEST_URI']);

# Chunk URI
$URI = $_SERVER['REQUEST_URI'];
$QUERYSTRING = explode("?", $URI);
$SEGMENTSTRING = explode("/", $QUERYSTRING[0]);
$SEGMENT = (count($QUERYSTRING) > 1) ? array_merge($SEGMENTSTRING, $QUERYSTRING) : $SEGMENTSTRING;
$FoundModule = false;
$ModFile = MOD_PATH . BASE_PAGE;


# Search Segments
for ($cx = 0; $cx < count($SEGMENT); $cx++) {
$FileSearch = MOD_PATH . $SEGMENT[$cx] . ".php";
if (file_exists($FileSearch) ) {
$Class = $SEGMENT[$cx];
$FoundModule = true;
$ModFile = $FileSearch;
$cx++;
break;
}
}


# Include the module File
require_once ($ModFile);


// If Module has found and has method Try to execute it
if (isset($SEGMENT[$cx]) && FoundModule) {
// If Class Exists
if (class_exists($Class)) {
// If Class Exists Include it.
if (isset($Class)) $obj = new $Class();

# Get The parameters

# If method Exists Call it
if (method_exists($obj, $SEGMENT[$cx])) {
$param = array_splice($SEGMENT, $cx+1);
call_user_method_array($SEGMENT[$cx], $obj, $param);
} else {
# If not Exists Try to call it the Class Method it self
if (method_exists($obj, $Class)) {
$param = array_splice($SEGMENT, $cx);
call_user_method_array($Class, $obj, $param);
}
}

# If Class Does not Exists Try Calling a Direct Function
} else
call_user_func_array($SEGMENT[$cx], array_splice($SEGMENT, $cx+1));
} else {
if (isset($Class))
$obj = new $Class();
else {
$Class = "Index";
$obj = new $Class();
}
}
?>

please help me with this one...
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Use of undefined constant

Post by Benjamin »

Please use [code tags when posting PHP code.
a2once
Forum Newbie
Posts: 4
Joined: Sun Jun 29, 2008 1:07 pm

Re: Use of undefined constant

Post by a2once »

can you show me how? please..
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Use of undefined constant

Post by Benjamin »

When you edit or post a topic you can press the code button.

[ code=php ]
code here
[ /code ]

without spaces it looks like:

Code: Select all

 
echo "hello world";
 
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Re: Use of undefined constant

Post by Stryks »

As for your problem, these errors usually mean that you are either trying to use an unquoted string ...

Code: Select all

$test = fred;
 
// instead of
 
$test = "fred";
... or you have left the $ from a variable ...

Code: Select all

$test = fred;
 
// instead of
 
$test = $fred;
... or perhaps you have just got the name of the constant wrong ...

Code: Select all

$test = FERD;
 
// instead of
 
$test = FRED;
Your first error is in the code you showed, and it seems to be the middle possibility.

Do a search of all the instances of FoundModule in that code, and see if you can see the odd one out. Then do the same for the second value, 'INCLUDE_PATH', although you will have to look in one of the included files to find the problem instance.

Cheers
a2once
Forum Newbie
Posts: 4
Joined: Sun Jun 29, 2008 1:07 pm

Re: Use of undefined constant

Post by a2once »

Thanks for the help of the two of you.. thank you thank you.. :lol:
Post Reply