The "Invalid argument supplied for foreach()" warning occures when you attempt to run a foreach-loop on a value that is not an array.
This frequently occures when you neglect to error check if the result returned from $this -> bot -> db -> select() is infact an array and not ie. false.
The code causing the warning here is probably
function battle_blob($pf)
{
if ($pf != null) {
$result = $this -> bot -> db -> select("SELECT time, off_guild, off_side, off_player, off_level, off_profession,
def_guild, def_side, zone, x_coord, y_coord FROM tower_attack WHERE zone LIKE '%$pf%' ORDER BY time DESC LIMIT 0, 20");
}
else {
$result = $this -> bot -> db -> select('SELECT time, off_guild, off_side, off_player, off_level, off_profession,
def_guild, def_side, zone, x_coord, y_coord FROM tower_attack ORDER BY time DESC LIMIT 0, 20');
}
if (!empty($pf)){
$battle = "<center><font color=CCInfoHeadline>:::: <u>Recent Tower Battles for ".$pf."</u> ::::</font></center>\n\n".'<font color=CCInfoText>';
}
else {
$battle = "<center><font color=CCInfoHeadline>:::: <u>All Recent Tower Battles</u> ::::</font></center>\n\n".'<font color=CCInfoText>';
}
foreach ($result as $res) {
Where the warning is generated by the last line. However that line is not the actual reason for the warning to be generated.
The reason is that the one of the above two calls to $this -> bot -> db -> select() that is actually called does not return any results.
This would be because there are no battles registered in the database. This should have been handled with a graceful exit, but such is omitted here. A graceful exit would look something like:
function battle_blob($pf)
{
if ($pf != null) {
$result = $this -> bot -> db -> select("SELECT time, off_guild, off_side, off_player, off_level, off_profession,
def_guild, def_side, zone, x_coord, y_coord FROM tower_attack WHERE zone LIKE '%$pf%' ORDER BY time DESC LIMIT 0, 20");
}
else {
$result = $this -> bot -> db -> select('SELECT time, off_guild, off_side, off_player, off_level, off_profession,
def_guild, def_side, zone, x_coord, y_coord FROM tower_attack ORDER BY time DESC LIMIT 0, 20');
}
if (empty($result))
{
return("No battles found");
}
if (!empty($pf)){
$battle = "<center><font color=CCInfoHeadline>:::: <u>Recent Tower Battles for ".$pf."</u> ::::</font></center>\n\n".'<font color=CCInfoText>';
}
else {
$battle = "<center><font color=CCInfoHeadline>:::: <u>All Recent Tower Battles</u> ::::</font></center>\n\n".'<font color=CCInfoText>';
}
foreach ($result as $res) {
Keep in mind that I have note checked the code nor looked closely if it will work or not. It is just an example.
Now, this still isn't the source of the problem which is that no battles has been entered into your battle table. Now if you've upgraded the TowerAttack module you also need to upgrade the table holding the data, or at the very least delete it.
I am suspecting that your log also contains warnings about MYSQL not being able to insert data into the tower_attack table as it is in the wrong format.
You can attempt to fix this by deleting the tower_attack table in your mysql database. To do this open the mysql command prompt and use the database that BeBot uses (refer to your conf/MySQL.conf file if you're uncertain about the details).
There you run the commands:
DROP TABLE tower_attack;
DROP TABLE tower_result;
When you re-start BeBot it should re-create the two tables in the right format. Now you just need to wait until someone kills some towers.
Also note that your bot needs to be in the top three ranks of your org to recieve the ALL TOWERS channel needed to populate the tower_attack table.
Hope that helps.