« Previous Next »

Thread: PHP Warning

Last post 11-25-2009 4:45 PM by don.raman. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 11-25-2009, 3:42 PM

    • Cjanuzi
    • Not Ranked
    • Joined on 11-25-2009, 8:03 PM
    • Posts 1

    PHP Warning

    Hello, we are migrating our application PHP+Linux+Apache to PHP+IIS7+WS08. Install and test PHP and is working, but when running our application, we received the error message:

    PHP Warning: Invalid argument supplied for foreach() in C:\inetpub\wwwroot\Web\index.php on line 13

    This is part of the code that we present the error.
    PHP does not understand the path indicated in the code
    Does anybody know any post or site that talks about this problem?

    header("P3P: CP=\"CAO PSA OUR\"");
    Session_start();
    Session_destroy();
    Session_start();
    $data_atual = mktime (0, 0, 0, date("m"), date("d"), date("Y"));
    foreach (glob("../temp/*",GLOB_NOCHECK ) as $filename) { This is the line 13
    if (file_exists($filename)) {
    $data_arquivo = mktime (0, 0, 0,
    date('m',filemtime($filename)),date('d',filemtime($filename)),date('Y',filemtime($filename)));
    if ($data_arquivo
    unlink($filename);
    }
    }
    }

    Thanks!!! (Or Help Me!!!)
  • 11-25-2009, 4:43 PM In reply to

    Re: PHP Warning

    Have you tried changing;

    ../temp/*

     to

    ..\temp\*

     You may also need to use double slashes.

    ----------------
    Dominic Ryan
    Microsoft IIS MVP
    www.iis-aid.com
    My IIS articles
    My PHP articles
    My How-to guides
  • 11-25-2009, 4:45 PM In reply to

    Re: PHP Warning

    Hi,

    I am not sure if the syntax is the problem. I have two folder named 'moodle' and 'phptest' inside folder 'C:\Inetpub\wwwroot'. I have a test program named 'test.php' inside 'phptest' folder which contains below code:

    <?php

    foreach (glob("../moodle/*",GLOB_NOCHECK ) as $filename)
    {
              echo $filename.'<br>';
    }

    ?>

    On running this code I get a perfectly valid output, I am pasting below bit of it as it is huge.

    ../moodle/CHANGES
    ../moodle/COPYING.txt
    ../moodle/README.txt
    ../moodle/admin
    ../moodle/auth
    ../moodle/backup
    ../moodle/blocks
    ../moodle/blog
    ../moodle/calendar
    ../moodle/config-dist.php
    ../moodle/config.php
    ../moodle/course
    ../moodle/enrol
    ../moodle/error
    ../moodle/file.php
    ../moodle/files
    ../moodle/filter
    ../moodle/grade
    ../moodle/group
    ../moodle/help.php

    I am using IIS7.0+PHP5.2.11.

    I also put up an invalid directory by changing code to:

    <?php

    foreach (glob("../moodle1232/*",GLOB_NOCHECK ) as $filename)
    {
     echo $filename."<br>";
    }

    ?>

    I still get the output in the browser as:

    ../moodle1232/*

    because of GLOB_NOCHECK flag.

    A smaller code to reproduce the problem will be very much helpful. Please try storing the output of glob function in an array and try printing it using print_r or something similar and see if there are any problems.

    Thanks,

    Don.

Page 1 of 1 (3 items)
Microsoft Communities