Wrong datatype for second argument

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dada1
    New Member
    • Jul 2008
    • 15

    Wrong datatype for second argument

    This is my script for counting file size in folders, but when I put this script on normal text page it shows error:
    Warning: in_array() [function.in-array]: Wrong datatype for second argument in statistics.php on line 20


    Code:
    <?php
    if (session_id() == ""){
    session_start();
    }
    $maxupload=1024000000; // in byte
    $dir='jdownloads';
    $notcount=array('index.html','listing.php','descriptionfile.txt');
    dirs($dir);
    $sizeinbyte=($_SESSION[tots]==0)?'0':$_SESSION[tots];
    $_SESSION[tots]=array();
    unset($_SESSION[tots]);
    function dirs($dir){
    global $notcount;
    if ($handle = opendir($dir)) {
    while (false !== ($file = readdir($handle))) {
     if ($file != "." && $file != "..") {
    if(is_dir($dir.'/'.$file)){
    dirs($dir.'/'.$file);
    }else{
    if (!in_array($file, $notcount)) {
    $fl=filesize($dir.'/'.$file);
    $_SESSION[tots]=$_SESSION[tots]+$fl;
    }
    }
    }
    }
    closedir($handle);
    }
    }
    ?>
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    I can't see why that is not working. Please try a simple script:
    Code:
    <?php
    $os = array("Mac", "NT", "Irix", "Linux");
    if (in_array("Irix", $os)) {
        echo "Got Irix";
    }
    if (in_array("mac", $os)) {
        echo "Got mac";
    }
    ?>
    If this works, modify it by parts to get it to look like your code running it after every change. That way you should be able to pin point where there is a problem.

    Comment

    • dada1
      New Member
      • Jul 2008
      • 15

      #3
      your script is not doing the same what mine do

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        Yeah I am just checking that your PHP is working as expected.

        Comment

        Working...