paulonline2501 Posted October 19, 2013 Share Posted October 19, 2013 (edited) hi everyone, i've got a script that works on one website, that lists files in a directory. ive moved the script to another website but now the script isnt working. the script: <ul><?php foreach (glob('../../_docs/*.*') as $file){ $file = basename($file); if ($file != 'index.php') {?> <li><?php echo"$file"?> <a href="../../_docs/<?php echo"$file"?>" target="_blank">[View]</a> <a href="../products/delete/?id=<?php echo"$file"?>">[Delete]</a></br> URL: http://xxxxxxxx.com/CYC/_docs/<?php echo"$file"?> </li> <?php } } ?></ul> the error: Warning: Invalid argument supplied for foreach() in/xxxxxxx/documents/index.php on line 188 [this refers to the line with the foreach glob in it] Edited October 19, 2013 by as_bold_as_love Link to comment Share on other sites More sharing options...
Ingolme Posted October 19, 2013 Share Posted October 19, 2013 Maybe glob() isn't returning what you think it is. Use var_dump() to see what glob is returning. $x = glob("..."); var_dump($x); Link to comment Share on other sites More sharing options...
paulonline2501 Posted October 19, 2013 Author Share Posted October 19, 2013 hi Foxy, if i put: $x = glob('../../_docs/*.*');var_dump($x); the result is: bool(false) Link to comment Share on other sites More sharing options...
Don E Posted October 19, 2013 Share Posted October 19, 2013 It's returning false because there is an error. Check to make sure your path is correct. Link to comment Share on other sites More sharing options...
Ingolme Posted October 19, 2013 Share Posted October 19, 2013 Goodness, you should try to understand what things mean rather than waiting for other people to tell you. The PHP manual page for glob() would explain it, of course. Returns an array containing the matched files/directories, an empty array if no file matched or FALSE on error. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now