Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 7 of 7

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 ...

  1. #1
    JPC Member
    Join Date
    Mar 2005
    Posts
    4

    1 error, pls help me !

    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

  2. #2
    Darth Admin (aka Jag) JPC-Greg's Avatar
    Join Date
    Sep 1998
    Posts
    5,201
    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

  3. #3
    JPC Member
    Join Date
    Mar 2005
    Posts
    4
    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 !

  4. #4
    the Windlord Gwaihir's Avatar
    Join Date
    Jun 2002
    Posts
    2,562
    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

  5. #5
    JPC Member
    Join Date
    Mar 2005
    Posts
    4
    in fact, some computers run fine, but some computer occured this error, I don't know why ????

  6. #6
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    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
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  7. #7
    Just Walking...
    Join Date
    Oct 2002
    Location
    England
    Posts
    436
    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 an
    Code:
    if (isset($lang['dayarray'])) { .... }
    round 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'].

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •