Array problem: function.reset: Passed variable is not an array or object

Discussion in 'PHP' started by beniwtv@hotmail.com, Mar 2, 2006.

  1. #1
    Hi!

    I'm having trouble with the following code:

    
    $sysip = "212.163.45.28";
    $snmpcomunity = "dataspain1724";
      
    for($i=1;$i < 256;$i++) {
    				$name = snmpget($sysip,$snmpcomunity, "ifDescr.".$i);
    				$status = snmpget($sysip,$snmpcomunity, "ifOperStatus.".$i);
    
    		        $data[$i]['Name'] = $name;
    		        $data[$i]['Status'] = $status;
     
    $html=$sign->parsetotable_ports($data,"mytddata","MyFieldName","MyOpenPort","MyClosedPort");
    
    PHP:
    The parsetotable function:
    
    function parsetotable_ports($result,$style,$style2)
    {
    
    for($i=0; $i < sizeof($result); $i++) 
    {
         if( $i == 0 )
        {
               $RES .= "<tr>\n";
               for($j=0; $j < sizeof($result[$i]); $j++)
              {
                  $RES .= "<td class=\"".$style2."\">".key($result[$i])."</td>\n";
                  next($result[$i]);
    								
             }
             reset($result[$i]); //Here's the error
            $RES .= "</tr>\n";
    						
    }
    
    PHP:
    ...

    The error is: Passed variable is not an array or object in the reset function of the function parsetotable_ports.

    Has anyone an idea?
    Thanks. Beni.
     
    beniwtv@hotmail.com, Mar 2, 2006 IP
  2. jordie

    jordie Peon

    Messages:
    7
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $result[0] doesn't exist. thats where it is starting....

    try changing:

    for($i=1;$i < 256;$i++) {

    to

    for($i=0;$i < 256;$i++) {

    or rather:

    for($i=0;$i < 255;$i++) {
     
    jordie, Mar 2, 2006 IP
    Crazy_Rob likes this.