This is my config load code:
$WConfig;
$lines = file($ToRootDirectory . 'config.txt', FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line_num => $line) {
$line = trim($line);
if (!(substr($line, 0, 1) == '#')){
$WConfig[(trim(substr($line, 0, strpos($line, ":"))))] = trim(substr($line, strpos($line, ':') + 1));
}
}
unset($lines, $line, $line_num, $temp);
$host = $WConfig['mshost']; //line 11
print_r($WConfig); //line 12
It loads this config file: (ANSI)
#--/ MySQL: //Dont forget to execute Install.sql ;)
# username: //NOT NEEDED TO BE ROOT -> Acces to INSERT, UPDATE, SELECT, SHOW
msusername:PHP_Default
# password:
mspassword:php
# database:
msdatabase:PHP_Default
# host:
mshost:localhost
#--/ Session:
# sessionend: Time in minutes when the session will be end from last acces. Default 20 minutes.
sessionend:20
But Displays:
Notice: Undefined index: mshost in C:\######\PHP\LoadConfig.php on line 11
Array ( [msusername] => PHP_Default [mspassword] => php [msdatabase] => PHP_Default [mshost] => localhost [sessionend] => 20 )
Line 11 gives a error because he can't find 'mshost' but if I display the array in line 12, 'mshost' still exists.
Who knows the answer of this problem and what do I need to do to fix this problem?
UPDATE: It only appears by msusername and mshost
ANSWER: I have changed msusername and mshost to numbers -> 0 and 1. That works fine.