1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Error_log issue (PHP Coding Problem)

Discussion in 'PHP & Perl' started by pathan420, Oct 22, 2012.

  1. pathan420

    pathan420 Newbie

    Joined:
    Jun 28, 2010
    Messages:
    16
    Likes Received:
    1
    Hello,

    I am using script to list files today I checked the directory where that script is uploaded and I can see that the error_log file was filled with tons of error messages I downloaded the error_log file and noticed the following errors.

    Code:
    [05-Oct-2012 12:13:56] PHP Warning:  array_multisort() [<a href='function.array-multisort'>function.array-multisort</a>]: Argument #1 is expected to be an array or a sort flag in /home/site/public_html/script/index.php on line 483 [05-Oct-2012 12:13:56] PHP Warning:  Invalid argument supplied for foreach() in /home/site/public_html/script/index.php on line 484
    
    on line 483 and 484 we have the following coding in index.php

    PHP:
    array_multisort($ftimes2,SORT_DESC,$ftimes);
         foreach (
    $ftimes as $readd) {
    Please help.
     
  2. bytzu

    bytzu Registered Member

    Joined:
    Jun 30, 2011
    Messages:
    96
    Likes Received:
    138
    The problem seems to be $ftimes2 not an array. Test using is_array function.

    if(is_array($ftimes2)){
    echo' ftimes2 is array';die();
    }else{
    echo ' ftimes2 is not an array';die();
    }

    If have no idea about what i am talking about PM me.I can help you if you want.
     
  3. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,066
    Likes Received:
    2,872
    Gender:
    Male
    Modify your script as the code below. Changes are highlighted. Close the brace after you foreach loop.
    Code:
    [COLOR=#b22222][B]if(is_array($ftimes2))[/B][/COLOR]
         array_multisort($ftimes2,SORT_DESC,$ftimes);
    
    
    [COLOR=#a52a2a][B]if(is_array($ftimes)) {[/B]
    [/COLOR]     foreach ($ftimes as $readd) {  
    
    ....
    ...
        } 
    [COLOR=#a52a2a][B]}[/B][/COLOR]