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...
Use of undefined constant
Moderator: General Moderators
Re: Use of undefined constant
Please use [code tags when posting PHP code.
Re: Use of undefined constant
can you show me how? please..
Re: Use of undefined constant
When you edit or post a topic you can press the code button.
[ code=php ]
code here
[ /code ]
without spaces it looks like:
[ code=php ]
code here
[ /code ]
without spaces it looks like:
Code: Select all
echo "hello world";
Re: Use of undefined constant
As for your problem, these errors usually mean that you are either trying to use an unquoted string ...
... or you have left the $ from a variable ...
... or perhaps you have just got the name of the constant wrong ...
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
Code: Select all
$test = fred;
// instead of
$test = "fred";Code: Select all
$test = fred;
// instead of
$test = $fred;Code: Select all
$test = FERD;
// instead of
$test = FRED;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
Re: Use of undefined constant
Thanks for the help of the two of you.. thank you thank you.. 