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? Quote 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 Quote 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 Quote 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. Quote 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 Quote 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))(...) Quote Link to comment https://forums.phpfreaks.com/topic/214910-notice-undefined-variable-icountfiles/#findComment-1118834 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.