I'm using a VPS at Jaguarpc. a error occured when customer visit my site.
Error:
Warning: Invalid argument supplied for foreach() in /home/mama/public_html/system/index.php on line 96
pls help me to resolve this problem !!!
La Tuan
This is a discussion on 1 error, pls help me ! in the Shared & Semi-Dedicated forum
I'm using a VPS at Jaguarpc. a error occured when customer visit my site.
Error:
Warning: Invalid argument supplied for foreach() in /home/mama/public_html/system/index.php on line ...
I'm using a VPS at Jaguarpc. a error occured when customer visit my site.
Error:
Warning: Invalid argument supplied for foreach() in /home/mama/public_html/system/index.php on line 96
pls help me to resolve this problem !!!
La Tuan
We need to see the source of line 96, in fact lines 95-97 to be able to help you.
Greg L. | Chief Executive Officer
JaguarPC.com
Helpful Links
Knowledge Base | Network Status
Need a Manager?
(pm) | (email) David, Customer Service Manager
(pm) | (email) Zach, Community Liason, Sales manager
(pm) | (email) Masood, Chief Technical Officer
(pm) | (email) Les, Chief Operations Officer
Here are in fact lines: 92-101
92 $news_array = array();
93 $i = 2;
94 $week = array();
95 $lang['dayarray'] = array("1","2","3","4","5","6","7");
96 foreach ($lang['dayarray'] as $day) {
97 while ($row = $sql->fetchrow()) {
98
99 unset($comments);
100 $sql2 = $db->Query("SELECT id FROM
101 ".PREFIX."_newscomments WHERE newsid='".$row->newsid."'");
102 $comments = $sql2->numrows();
pls help me, thanks !
I copy-pasted this foreach and the stuff above it and it runs fine :?
Regards,
Wim Heemskerk
---
Visit MeCCG.net - Cardgaming in J.R.R. Tolkien's Middle-earth
And Gwaihir.net - The Middle-earth CCG store
in fact, some computers run fine, but some computer occured this error, I don't know why ????
I see no reason why this wouldn't work. PHP runs on the server with the output of the script being returned to the user's browser, so it should work consistantly on every computer that hits it.
The only thing that I can think of that would cause an error like that one is the variable you pass into foreach() being something other than an array, but from the code you pasted it looks impossible for $lang['dayarray'] to be anything but an array.
Are there any special circumstances in which this script stops working that yoou've noticed? Do you pass any variables to it by submitting a form or by adding a query sting to the URL? Are you using sessions or cookies at all? Just some thoughts that might help you isolate the problem...
--Jason
I have often run into strange problems with PHP. Variables/arrays which should not be empty being so etc. It is incredibly frustrating and I've never adequately been able to explain it. I've wondered if it wasn't due to the way PHP actually parses the code, my understanding is that it uses a two-pass system which might cause these sorts of problems. Alternatively it might be due to optmizers like Zend Optimizer which are used on Jag servers.
Try sticking anround that foreach. Strange as it sounds in a couple of cases that has fixed the problem for me, it is suddenly able to see $lang['dayarray'].Code:if (isset($lang['dayarray'])) { .... }
Copyright © 2011 JaguarPC.com
Bookmarks