[Mapserver-users] why --> msQueryByAttributes(): Queryerror. No query expressiondefined

David Fawcett David.Fawcett at state.mn.us
Wed Jul 7 09:49:37 EDT 2004


Javier, 

The syntax for itemqueries changed after version 3.5 or so.  

Queries no longer use a filter in the Map file.  Instead, you need to
pass the variables 'qlayer', 'qitem', and 'qstring' in the URL.  They
are documented here: 
http://mapserver.gis.umn.edu/doc42/cgi-reference.html#qitem 

It should look something like:

...&qlayer=layer1&qitem=FIELD2&qstring=('[FIELD2]'='10')

&qlayer=provin&qitem=NOMBRE&qstring='Juarez'

(This assumes that there is a 'provin' with the name 'Juarez'.  If you
build this URL string dynamically in the form at the bottom of this
message, it should look something like this:  

<td><img border="2"
src="[mapserv]?map=[map]&name=&mode=itemquerymap&mapext=shapes&qlayer=provin&qitem=NOMBRE&qstring='[name_esc]'
" height="300" width="300"></td>

David.



David J. Fawcett
MN Office of Environmental Assistance

>>> Javier Castillejo Montes <jcastil1 at tragsa.es> 7/7/2004 2:08:37 AM
>>>
Hi,
mapserv_41.exe is the exe im using... the wrong thing could be my code,
that
is obsolete.

I took the code from a web page and translate it into my needs.... 

Javier

-----Mensaje original-----
De: David Fawcett [mailto:David.Fawcett at state.mn.us] 
Enviado el: martes, 06 de julio de 2004 16:58
Para: mapserver-users at lists.gis.umn.edu; Javier Castillejo Montes
Asunto: Re: [Mapserver-users] why --> msQueryByAttributes():
Queryerror.
No query expressiondefined


I may be mistaken, but the example looks a little old.  What version
of
MapServer are you using?  

David.

David J. Fawcett
MN Office of Environmental Assistance

>>> Javier Castillejo Montes <jcastil1 at tragsa.es> 7/6/2004 8:00:55 AM
>>>
Hi all,
 

Does anyone know why this code has an error. I'm just trying to use a
mapserver example  from the internet, I copied the code made the
changes
necesaries and... ERROR!!!! :-(
 

### ERROR:  
  msQueryByAttributes(): Query error. No query expression defined.
 
### main html
 

<html>
<body>
<form name="mapserv" method="get"
action="//[host]/scripts/mapserv.exe">
<input type="text" name="mapserv" value="//[host]/scripts/mapserv.exe"
size=100%>
<input type="text" name="map" value="[path]/map/case1.map" size=100%>
<input type="text" name="map_web_imagepath" value="[path]/tmp/" 
size=100%>
<input type="text" name="map_web_imageurl" value="[path]/tmp/">
<input type="text" name="mode" value="itemquery"  size=100%>
<input type="text" name="qlayer" value="provin"  size=100%>
 
<br><br><br><br><br><br>
Select
 
<input type="text" name="name" id="name" value="mad">
 
<br>
 
<input type="submit" value="Go!">
 
</form>
</body>
</html>
 

## map file
 
MAP
  NAME case1
  SHAPEPATH      "../data"
  SIZE 300 300
  EXTENT -50000 4000000 1100000 4800000
 
  WEB
    IMAGEPATH '../data/tmp/'
    IMAGEURL  '../data/tmp/'
  END
 
  QUERYMAP
    STATUS ON
    STYLE HILITE
    COLOR 255 255 0
  END
 
  LAYER
    NAME provin
    DATA provin
    STATUS DEFAULT
    TYPE POLYGON
    FILTERITEM nombre
    FILTER "%name%"
    CLASS
      COLOR 212 212 212
      OUTLINECOLOR 0 0 0
      TEMPLATE "../html/case1_template.html"
    END
  END
 
END
 

### template file
 
<html>
<head>
  <title>MapServer Test Suite - ItemQuery</title>
</head>
 
<body bgcolor="#ffffff">
 
<font size="+2" face="arial,helvetica"><b>Case 1: Simple ItemQuery
With
QueryMap</b></font>
 
<p>
 
This is just a simple dump of a few attributes for an individual
polygon
in the test suites counties layer:
 
<p>
 
<b>Name:</b> [Name]<br>
<b>ID Provincia:</b> [prov]<br>
<b>Comunidad Code:</b> [Comunidadc]<br>
 
<p>
 
and here's the map of the query results (you can zoom to a set of
results as
well):
 
<p>
 
<table cellpadding="5">
<tr>
<td><img border="2" src="[img]" height="300" width="300"></td>
<td><img border="2"
src="[mapserv]?map=[map]&name=[name_esc]&mode=itemquerymap&mapext=shapes&qla
yer=[qlayer]" height="300" width="300"></td>
</tr>
</table>
 
</body>
</html>
 
 
thanks in advance



More information about the mapserver-users mailing list