Header Warning Inva...
 
Notifications
Clear all

Header Warning Invalid argument supplied for foreach()

11 Posts
3 Users
0 Reactions
1,712 Views
(@becca)
Posts: 553
Honorable Member
Topic starter
 

URL to your eFiction: http://blacklashed.net
Version of eFiction: 3.5.1
Have you bridged eFiction, if so with what?: no
Version of PHP: 5.2.9
Version of MySQL: 5
Have you searched for your problem: yes
If so, what terms did you try: header.php, header, Warning: Invalid argument supplied for foreach()
State the nature of your problem:

Warning: Invalid argument supplied for foreach() in /home/user/public_html/header.php

Do you have a test account for us? n/a

I am trying to resolve to see if this is an issue with the server, or a random eFiction problem. I tried replacing header.php with the latest SVN but it did not fix anything. The site is redirecting to maintenance yet when I check in the MySQL database, and maintenance is set to '0'.

I haven't made any changes to any files otherwise, and the site is inaccessible. I personally did not edit any files, so unless mmlands (who I am currently hosting, as this is my server) has modified any header files, then I'm not entirely sure what should be causing this.

Another eFiction install is working just fine on the server, yet I seem to be having a problem with this one and one other one.

Thanks in advance for any suggestions or help.


 
Posted : 13/07/2009 1:12 pm
(@lyndsie)
Posts: 1263
Member Moderator
 

There's no numbers or anything given? There's a ton of foreach() in there. : (


 
Posted : 13/07/2009 5:12 pm
(@becca)
Posts: 553
Honorable Member
Topic starter
 

Nope no numbers. My support tech is trying to fix this. It seems like the settings tables got corrupted on 2 of the sites and my backups are corrupted/won't let me restore the databases.

He tried to re-create the settings table, but now whenever you visit either site you get directed to maintenance mode. Would anyone (Tammy :D) be able to make an SQL query to re-create the settings table?

I'm thinking my best option would be to re-install eFiction and then just re-install/import the rest of the data and hopefully the only thing that would need to be re-made would be the settings, which is the least of our problems. I'm just worried about the users, stories, reviews etc.


 
Posted : 13/07/2009 5:22 pm
(@lyndsie)
Posts: 1263
Member Moderator
 

The structure & default contents for the settings table is definitely in install/install.php. Can you not just pull it out of there and make it it's own PHP file, and run it? (Or is that part of the issue?)


 
Posted : 13/07/2009 5:38 pm
(@becca)
Posts: 553
Honorable Member
Topic starter
 

I'm thinking of doing that but the problem I would run into would be the sitekey. I would need a new one to be generated, as the settings tables got corrupt? (It's also late over here and I might just be getting settings.php confused)


 
Posted : 14/07/2009 1:44 am
(@lyndsie)
Posts: 1263
Member Moderator
 

I think it would be okay so long as the sitekey in fanfiction_settings matches the one in config.php (if there is one? Maybe that field gets left blank for whatever reason). I've never been really clear on how that works, though. : /  I think maybe config.php pulls it from the database, just judging by the last two lines in there. It's also late here, lol.


 
Posted : 14/07/2009 3:20 am
(@becca)
Posts: 553
Honorable Member
Topic starter
 

I forgot that the installation tables are also in the /docs folder, so I tried re-creating the settings table and I'm thinking that's not the problem. I replaced the sitekey with the one from config.php. I'm stilling getting the same foreach() warning and it will change the line (no matter if I use the SVN or 3.5.1). It seems to be this line giving me the error:

foreach($settings as $var => $val) {

On the next line however something looks fishy:

$$var = stripslashes($val);

I don't think $$var should have two '$'s? I tried changing that to $var, but it did little good.

Taking a look at my error logs as well seemed to have turned this up:

[Wed Jul 15 11:42:33 2009] [error] [client 24.186.246.253] File does not exist: /home/noel/public_html/404.shtml, referer:  http://blacklashed.net/maintenance.php 
[Wed Jul 15 11:42:34 2009] [error] [client 24.186.246.253] PHP Warning:  Invalid argument supplied for foreach() in /home/noel/public_html/header.php on line 88
[Wed Jul 15 11:42:35 2009] [error] [client 24.186.246.253] File does not exist: /home/noel/public_html/skins/style.css, referer: http://blacklashed.net/maintenance.php
[Wed Jul 15 11:42:35 2009] [error] [client 24.186.246.253] File does not exist: /home/noel/public_html/404.shtml, referer: http://blacklashed.net/maintenance.php
[Wed Jul 15 11:42:35 2009] [error] [client 24.186.246.253] File does not exist: /home/noel/public_html/skins/style.css, referer: http://blacklashed.net/maintenance.php
[Wed Jul 15 11:42:35 2009] [error] [client 24.186.246.253] File does not exist: /home/noel/public_html/404.shtml, referer: http://blacklashed.net/maintenance.php
[Wed Jul 15 11:42:39 2009] [error] [client 24.186.246.253] PHP Warning:  Invalid argument supplied for foreach() in /home/noel/public_html/header.php on line 88
[Wed Jul 15 11:42:39 2009] [error] [client 24.186.246.253] PHP Warning:  Invalid argument supplied for foreach() in /home/noel/public_html/header.php on line 88
[Wed Jul 15 11:42:39 2009] [error] [client 24.186.246.253] File does not exist: /home/noel/public_html/skins/style.css, referer: http://blacklashed.net/maintenance.php
[Wed Jul 15 11:42:39 2009] [error] [client 24.186.246.253] File does not exist: /home/noel/public_html/404.shtml, referer: http://blacklashed.net/maintenance.php

maintenance.php exists and I'm not sure why it's trying to redirect to 404.shtml


 
Posted : 15/07/2009 1:53 pm
 Elle
(@jenny)
Posts: 594
Honorable Member
 

The double $ is all right, and probably intentional; it's writing itself a "new" variable. I don't know if there's an actual term for what it's doing, but basically the loop is something like this:

The arrays are:
$var = a, b, c
$val = d, e, f

The loop is:

foreach ($var as $val) {
$$var = $val;
}

In non-abstract-y terms, these variables would be written:

$a = d;
$b = e;
$c = f;

It's weird, but it's one of those PHP-worky things. πŸ˜›

Anyway, you mentioned something about the settings table being corrupted. It's probably the $settings.

$settingsresults = dbquery("SELECT * FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");

You could probably try editing the WHERE to something else; that seems weird because config sitekey equals the one in the settings table, right? =/ Maybe WHERE sitename = 'Blacklashed' See what that does. All you need to do is pull up a row in fanfiction_settings. o_O

The maintenance redirection is caused by an empty sitekey, though I'm not sure why it'd want to redirect to 404. =/ Strange.


archive: dramione.org
site: accio.nu

Available for skin/mod commission! πŸ™‚

 
Posted : 15/07/2009 5:47 pm
(@lyndsie)
Posts: 1263
Member Moderator
 

Just a note. The last time I looked in the docs folder at the SQL files, they weren't all up to date (which is why I tell people to look in install.php; also because it gives more info about all that goes down). It might be okay for the settings table, though. And I haven't looked in a while, either.


 
Posted : 15/07/2009 6:51 pm
(@becca)
Posts: 553
Honorable Member
Topic starter
 

Yeah, I realized that when I tried to re-install the settings table manually. It turned out that other tables had also vanished. I'm so frustrated and confused as to how this happened. Thanks for your suggestions Lyndsie and Jenny.

I was able to restore the site with an old backup. Some of the stories, chapters and series are missing. They seem the be there in files but is there any way we could do a reversal of some sort? Have the them re-added through the files. I don't think so, or it would be complicated, but it's worth asking.


 
Posted : 16/07/2009 12:47 pm
(@lyndsie)
Posts: 1263
Member Moderator
 

Since there's so many tables at play with something like that, as well as the numerical system, I think the easiest would be to download & delete off the server the orphaned chapters, and then reupload them through the regular upload system. I had at one point to upload a backup during an upgrade, and the last three or so chapters posted got effectively deleted. They were still in the stories folder, of course, but I just sent the authors the text (as .txt so they wouldn't have to redo the formatting) and asked them to reupload, with my apologies, because I wouldn't have known things like all their classification & character selections.

Of course, depending on the number you're talking about and if anyone in the admins would happen to know this information, then perhaps you could do it for them.


 
Posted : 16/07/2009 5:07 pm
Share: