Faqts

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

got segmentation fault when echo each element through an array a for loop

Nov 8th, 2006 08:54
Andy Fu,


Hi All:
I have an array named $machineNames which already have data in it, now I
 got a segmentation fault from the code below:
(This code works fine with PHP4, but not with PHP5, Thanks a lot for help!)
The problem occured at echo line:
    echo '<div dojoType="TreeNode" title="'.$machineNames[$i].'"
widgetId="'.$machineNames[$i].'"  objectId="root" isFolder="true">';
--------------code----------------------------
<?php
for($i=0; $i< $machineNum; $i++)
  {
    echo '<div dojoType="TreeNode" title="'.$machineNames[$i].'"
widgetId="'.$machineNames[$i].'"  objectId="root" isFolder="true">';
    $sql="select distinct category from aclog where
machine='".$machineNames[$i]."' order by category";
    $result1 = @sybase_query($sql, $connection) or die ("Could not
execute Sybase SQL query.");
    $nums = @sybase_num_rows($result1);
    for($j=0; $j<$nums; $j++)
      {
        $tmpcat =sybase_result($result1, $j, "category");
        echo '<div dojoType="TreeNode" title="'.$tmpcat.'"
widgetId="'.$tmpcat.'___'.$i.'_'.$j.'"  objectId="'.$machineNames[$i].'"
isFolder="false"></div>';
      }
    echo '</div>';
  }?>