This problem is due to the new single pass query in 5.6.
I have marked your code with what I am using. Try these mods marked with "*************************": @$datQuery = $query_layer->queryByRect($qRect); //number of objects $resnum = $query_layer->getNumResults(); echo "number of objects: ".$resnum."<br>"; //if query success if ($datQuery == MS_SUCCESS) { // $query_layer->open(); // <<REMOVE OPEN AND CLOSE *********** //first row $result = $query_layer->getResult(0); //$shpobj = $query_layer->getShape($result->tileindex,$result->shapeindex); // resultsGetShape is now the way to get the shape object *************************** // note: change of order in arguments ************************************************ $shpobj = $query_layer->resultsGetShape($result->shapeindex, $result->tileindex); //read attribute $attr = $shpobj->values; //write headline echo '<table cellspacing="0" cellpadding="2" border="1" ><tr>'; foreach($attr as $name=>$wert) { echo '<td bgcolor="#CCCCCC">'.$name.'</td>'; } echo '</tr>'; //write datasets for ($j=0; $j<$query_layer->getNumResults(); $j++) { $result = $query_layer->getResult($j); //$shpobj = $query_layer->getShape($result->tileindex,$result->shapeindex); // see note above ********************************************************************** $shpobj = $query_layer->resultsGetShape($result->shapeindex, $result->tileindex); $ri = $result->tileindex; $si = $result->shapeindex; $attr = $shpobj->values; echo '<tr id="row'.$si.'" >'; foreach($attr as $name=>$wert) { echo '<td>'.$wert.'</td>'; } echo '</tr>'; $shpobj->free(); } // $query_layer->close(); // <<REMOVE OPEN AND CLOSE *********** echo '</table>'; } // end success ... -----Original Message----- From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Sven Schroeter Sent: Thursday, March 25, 2010 10:52 AM To: mapserver-users@lists.osgeo.org Subject: Re: [mapserver-users] php mapscript Alan, thanks for the reply, I tried it with getFeature(), but there comes the same error. nextShape() works only after msWhichShapes and here I need a rectobj. But I want to use the script for queryByShape and queryByAttributes too. Why there comes no array in $attr = $shpobj->values; ? Any idea? Sven ----- Original Message ----- From: "Alan Boudreault" <aboudrea...@mapgears.com> To: <mapserver-users@lists.osgeo.org> Cc: "Sven Schroeter" <schroe...@netgis.de> Sent: Thursday, March 25, 2010 2:32 PM Subject: Re: [mapserver-users] php mapscript > Sven, > > getShape() is deprecated. Use rather getFeature(). I suggest to also take > a > look at the nextShape() function: > http://mapserver.org/mapscript/php/index.html#layerobj-class > > Alan > > On March 25, 2010 09:18:50 am Sven Schroeter wrote: >> Hi, >> I have an old php mapscript code that works fine with mapserver 5.02 or >> 5.2, but not with 5.6.1. >> The code runs an attribute tabe from a postgis layer and different querys >> i.e. queryByRect: >> >> ... >> @$datQuery = $query_layer->queryByRect($qRect); >> >> //number of objects >> $resnum = $query_layer->getNumResults(); >> echo "number of objects: ".$resnum."<br>"; >> >> //if query success >> if ($datQuery == MS_SUCCESS) { >> $query_layer->open(); >> >> //first row >> $result = $query_layer->getResult(0); >> $shpobj = >> $query_layer->getShape($result->tileindex,$result->shapeindex); >> //read attribute >> $attr = $shpobj->values; >> >> //write headline >> echo '<table cellspacing="0" cellpadding="2" border="1" ><tr>'; >> foreach($attr as $name=>$wert) { >> echo '<td bgcolor="#CCCCCC">'.$name.'</td>'; >> } >> echo '</tr>'; >> >> //write datasets >> for ($j=0; $j<$query_layer->getNumResults(); $j++) { >> $result = $query_layer->getResult($j); >> $shpobj = >> $query_layer->getShape($result->tileindex,$result->shapeindex); $ri = >> $result->tileindex; >> $si = $result->shapeindex; >> $attr = $shpobj->values; >> echo '<tr id="row'.$si.'" >'; >> foreach($attr as $name=>$wert) { >> echo '<td>'.$wert.'</td>'; >> } >> echo '</tr>'; >> $shpobj->free(); >> } >> $query_layer->close(); >> echo '</table>'; >> >> } // end success >> ... >> >> In ms 5.6.1 the query is also successful (I get the correct number of >> objects) but there comes following warning: >> Invalid argument supplied for foreach() in ... Fatal error: Call to a >> member function free() on a non-object in ... >> No object? Why? What has changed? >> Thanks >> Sven >> >> >> >> _______________________________________________ >> mapserver-users mailing list >> mapserver-users@lists.osgeo.org >> http://lists.osgeo.org/mailman/listinfo/mapserver-users >> > > -- > Alan Boudreault > Mapgears > http://www.mapgears.com > > _______________________________________________ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users