SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Mar 2013
    0 Post(s)
    0 Thread(s)

    valid php4 code throws 'invalid index' in php5

    FATAL ERROR; 'invalid index' thrown by working php4 code when run with php5.

    Web searchs turned up 3 possible corrections (none worked):
    1) use error_reporting(E_ALL & ~E_NOTICE | ~E_DEPRECATED);
    2) initialize offending array;
    3) offending array is not an array -- be sure to declare it.

    * defined array: $buffer = array(); Checked with is_array($buffer), which says it is an array.
    * opened source file: $fh = fopen($_SERVER{'DOCUMENT_ROOT'}. /.../.../kvpisow2.txt file
    * loaded $buffer $buffer = fgets($fh).
    * tested result using is_array($buffer)? NO! it is not an array.
    * treated $buffer as if an array and tried to set each $value = null (for initialization)
    * then did echo var_dump($buffer) and got original source displayed as the originally desired array (but without any 'null' values.

    Any suggestions on what to try next will be appreciated -- worked too long on this one!

    Thanks for any ideas

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    19 Post(s)
    1 Thread(s)
    Quote Originally Posted by usit View Post
    Use square brackets instead of curly braces.
    "First make it work. Then make it better."


Posting Permissions

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