DJSnels Posted October 1, 2010 Share Posted October 1, 2010 Ik ben bezig met een gastenboek en snap de volgende foutmelding niet: Notice: Undefined variable: iCountFiles *************** regel 261 //Smilies toegestaan?if ($GetConfiguratie['smiley'] == 1){$AfbeeldingenPerRegel = 12 ; if (!$rHandle = opendir('./images/smilies')) {$sP_Smilies = 'Geef de map "smilies" leesrechten!';} else {$sP_Smilies = ''; while (false !== ($sFile = readdir($rHandle))) {if (preg_match("/^([sa-zA-Z0-9]+){3}(:?\.gif|\.jpg)$/", $sFile)) { $sFileShort = preg_replace("/^([sa-zA-Z0-9]+)(:?\.gif|\.jpg)$/", "(\\1)",$sFile); $iCountFiles++ ; /////////////////////////////////////////////////////////////REGEL261 if ($iCountFiles % $AfbeeldingenPerRegel == 0) {$sP_Smilies .= '<img onClick="insertSmilie(\''.$sFileShort.'\')" src="images/smilies/'.$sFile.'" alt="code: '.$sFileShort.'" /><br />';} else {$sP_Smilies .= '<img onClick="insertSmilie(\''.$sFileShort.'\')" src="images/smilies/'.$sFile.'" alt="code: '.$sFileShort.'" /> ';} } } closedir($rHandle); }} hoe los ik dit het best op? Link to comment https://forums.phpfreaks.com/topic/214910-notice-undefined-variable-icountfiles/ Share on other sites More sharing options...
Philip Posted October 1, 2010 Share Posted October 1, 2010 can you pass the mustard? thx Link to comment https://forums.phpfreaks.com/topic/214910-notice-undefined-variable-icountfiles/#findComment-1117987 Share on other sites More sharing options...
DJSnels Posted October 4, 2010 Author Share Posted October 4, 2010 can you pass the mustard? thanks Link to comment https://forums.phpfreaks.com/topic/214910-notice-undefined-variable-icountfiles/#findComment-1118825 Share on other sites More sharing options...
Adam Posted October 4, 2010 Share Posted October 4, 2010 Not many will speak German (?) here. Link to comment https://forums.phpfreaks.com/topic/214910-notice-undefined-variable-icountfiles/#findComment-1118827 Share on other sites More sharing options...
DJSnels Posted October 4, 2010 Author Share Posted October 4, 2010 I´m corrently creating aq guestbook and i´m getting the following errormessage: Notice: Undefined variable: iCountFiles *************** line 261 //Smilies toegestaan?if ($GetConfiguratie['smiley'] == 1){$AfbeeldingenPerRegel = 12 ; if (!$rHandle = opendir('./images/smilies')) {$sP_Smilies = 'Geef de map "smilies" leesrechten!';} else {$sP_Smilies = ''; while (false !== ($sFile = readdir($rHandle))) {if (preg_match("/^([sa-zA-Z0-9]+){3}(:?\.gif|\.jpg)$/", $sFile)) { $sFileShort = preg_replace("/^([sa-zA-Z0-9]+)(:?\.gif|\.jpg)$/", "(\\1)",$sFile); $iCountFiles++ ; ///////////////////////////////////////////////////////////// THIS IS LINE 261 if ($iCountFiles % $AfbeeldingenPerRegel == 0) {$sP_Smilies .= '<img onClick="insertSmilie(\''.$sFileShort.'\')" src="images/smilies/'.$sFile.'" alt="code: '.$sFileShort.'" /><br />';} else {$sP_Smilies .= '<img onClick="insertSmilie(\''.$sFileShort.'\')" src="images/smilies/'.$sFile.'" alt="code: '.$sFileShort.'" /> ';} } } closedir($rHandle); }} How to solve this? EDIT: translated to english, sorry for that Link to comment https://forums.phpfreaks.com/topic/214910-notice-undefined-variable-icountfiles/#findComment-1118833 Share on other sites More sharing options...
Adam Posted October 4, 2010 Share Posted October 4, 2010 It's because you're trying to increment a variable that hasn't been defined. Set $iCountFiles to 0 before the loop: (...) {$sP_Smilies = ''; $iCountFiles = 0; while (false !== ($sFile = readdir($rHandle))) {if (preg_match("/^([sa-zA-Z0-9]+){3}(:?\.gif|\.jpg)$/", $sFile))(...) Link to comment https://forums.phpfreaks.com/topic/214910-notice-undefined-variable-icountfiles/#findComment-1118834 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.