tags:

views:

74

answers:

3

Please help me again! I have problems with this code:

<?php
  $pathThemes = INC_DIR . "themes";
  $d = dir($pathThemes);
  while (false !== ($entry = $d->read())) {
    $fileInfo = pathinfo($pathThemes . '/' . $entry);

    if ('php' == $fileInfo['extension']) {
      include_once($pathThemes . '/' . $entry);
      $name = $fileInfo['filename'];
      if (!$GLOBALS['fc_config']['themes'][$name]['name']) {
        unset($GLOBALS['fc_config']['themes'][$name]);
      }
    }
  }
?>

It says me:

Notice: Undefined index: name in C:\wamp\www\FlashChat_v607\chat\inc\include_themes.php on line 10

Notice: Undefined index: name in C:\wamp\www\FlashChat_v607\chat\inc\include_themes.php on line 10

Notice: Undefined index: name in C:\wamp\www\FlashChat_v607\chat\inc\include_themes.php on line 10

Notice: Undefined index: name in C:\wamp\www\FlashChat_v607\chat\inc\include_themes.php on line 10

+2  A: 

try using isset( $GLOBALS['fc_config']['themes'][$name]['name'] ) with the not

chelfers
the problem still exists:(
Marin
@Marin: isset works differently for you than everyone else? Prove it. Post the new code.
webbiedave
<?php $pathThemes = INC_DIR . "themes"; $d = dir($pathThemes); while (false !== ($entry = $d->read())) { $fileInfo = pathinfo($pathThemes . '/' . $entry); if ('php' == $fileInfo['extension']) { include_once($pathThemes . '/' . $entry); $name = $fileInfo['filename']; if (!$GLOBALS['fc_config']['themes'][$name]['name']) { !isset( $GLOBALS['fc_config']['themes'][$name]['name'] ) } } }?>
Marin
It doesn't work:(
Marin
Give me the full corrected code plz;)
Marin
Marin: First of all, calm down. Second, put the code you tried into the original question so that it can be formatted correctly. Third, don't *demand* "full corrected code". If something didn't work, then we simply need to explore the problem in greater depth. People here aren't trying to trick you, but neither are they here to do your bidding; they're spending their own time to help you out of courtesy. Be polite, learn how to use this site, and don't treat it as a substitute for expending some effort to solve your own problems or for learning on your own.
Tyler McHenry
I'm so sorry if I sounded rude,I didn't mean that:( Sorry to all,but I am anxious cause I have to deliver the project on Monday and I don't have enough time to finish it!I will post below the first code,that generates me an error.Thnx 4 helping me:)
Marin
This is the code:<?php $pathThemes = INC_DIR . "themes"; $d = dir($pathThemes); while (false !== ($entry = $d->read())) { $fileInfo = pathinfo($pathThemes . '/' . $entry); if ('php' == $fileInfo['extension']) { include_once($pathThemes . '/' . $entry); $name = $fileInfo['filename']; if (!$GLOBALS['fc_config']['themes'][$name]['name']) { unset($GLOBALS['fc_config']['themes'][$name]); } } }?>
Marin
Marin: It's nearly impossible to read code that is posted in comments. Go back and edit your original question at the top of the page to include the new code that you tried and didn't work, so that it can be formatted properly and people can take a look at it.
Tyler McHenry
@Marin: The problem is that any of the "subarrays" in `$GLOBALS['fc_config']['themes'][$name]['name']` may not exist. What does `print_r($GLOBALS)` or `print_r($GLOBALS['fc_config'])` give you? Check that every index exist, also the one that is represented with `$name`. If there is indeed some index missing, we cannot help you, it is your code, you are building the array somewhere.
Felix Kling
The code in the top of the page is the original I downloaded from the internet!If you want I can post it to another link like speedyshare and you can get the code:)
Marin
@Marin: So you only downloaded this piece of code and nothing else?
Felix Kling
No,I have downloaded the whole script in rar and when I added it to www directory in wamp it has generated some errors,some of them I have resolved,thanx to the other guys,but I have this trouble now that won't let me go on:(
Marin
+2  A: 
if (!isset($GLOBALS['fc_config']['themes'][$name]['name'])) {

take a look at the isset function

erenon
can you say me what to do?how to repair it?
Marin
+1  A: 

Try this:

  if (!empty($name) && isset($GLOBALS['fc_config']['themes'][$name]['name'])) {
    unset($GLOBALS['fc_config']['themes'][$name]);
  }
Eric Petroelje
it doesn't work:(
Marin