Jump to content

Notice: Undefined variable: iCountFiles


DJSnels

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.