tarantoo Posted July 14, 2012 Share Posted July 14, 2012 Hello, Dear friends can you help me with this piece of code.. <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $host = ""; // your mysql server address $user = ""; // your mysql username $pass = ""; // your mysql password $databasename = ""; // your mysql database session_start(); $data = null; if(!(@mysql_connect("$host","$user","$pass") && @mysql_select_db("$databasename"))) { exit; } include_once 'functions.php'; require_once "includes/pluggable.php"; foreach( glob("plugins/*/index.php") as $plugin) { require_once($plugin); } hook_action('initialize'); $site = mysql_fetch_object(mysql_query("SELECT * FROM settings")); ?> I am keep getting warning error for line 22... this line:" foreach( glob("plugins/*/index.php") as $plugin) { " it says PHP warning: Invalid argument supplied for foreach() Can somebody please help me recode it, or tell me what is the problem? I know that is array problem, but don't know how to fix this btw. Can this be host error? Thanks ahead! Quote Link to comment Share on other sites More sharing options...
hakimserwa Posted July 14, 2012 Share Posted July 14, 2012 foreach is only used on arrays what are trying to archive? Quote Link to comment Share on other sites More sharing options...
scootstah Posted July 14, 2012 Share Posted July 14, 2012 It is because glob() has failed and returned false. foreach is only used on arrays what are trying to archive? foreach() can be used for objects too, and glob() returns an array (unless it fails). Quote Link to comment Share on other sites More sharing options...
tarantoo Posted July 14, 2012 Author Share Posted July 14, 2012 It is because glob() has failed and returned false. -- and how to fix this? Quote Link to comment Share on other sites More sharing options...
scootstah Posted July 14, 2012 Share Posted July 14, 2012 Possibly an incorrect file path, or it isn't readable. Quote Link to comment Share on other sites More sharing options...
tarantoo Posted July 14, 2012 Author Share Posted July 14, 2012 Can I use something else, something without glob() ? Quote Link to comment Share on other sites More sharing options...
hakimserwa Posted July 25, 2012 Share Posted July 25, 2012 php is voltile there is always a solution Quote Link to comment Share on other sites More sharing options...
jcbones Posted July 26, 2012 Share Posted July 26, 2012 Do you have a plugins folder? Does the plugins folder have other folders inside them? Is the plugins folder readable? Is the plugins folder residing inside the same folder as the running script? Quote Link to comment Share on other sites More sharing options...
Paid Posted May 2, 2013 Share Posted May 2, 2013 (edited) Solved! Swapper [<<<<< foreach( glob("./plugins/*/index.php") as $plugin) {>>>> ] Edited May 2, 2013 by Paid Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.