Jump to content

[help] Searh Attribute Using Querybyattributes In Phpmapscript


eko_wardoyo
 Share

Recommended Posts

i have some problem about search attribute using function querybyattributes in phpmapscript. i use postgis for search spatial data.here is the script:<?$qlayer=strtolower($_GET["qlayer"]); $qitem=strtolower($_GET["qitem"]); $qstring=strtoupper($_GET["qstring"]); $querystring=strval($qstring); if(!empty($qlayer)&&!empty($qitem)&&!empty($qstring)){ $oLayerString=$GLOBALS["map"]->getLayerByName($qlayer); $myquery=$oLayerString->queryByAttributes($qitem,$qitem."=".$querystring,MS_SINGLE); $GLOBALS["gShowQueryString"]=TRUE; } ?>and here is the error that i have got:Warning: [MapServer Error]: prepare_database(): Error declaring cursor: ERROR: syntax error at or near "NGANTANG" LINE 1: ...,'NDR'),gid::text from client WHERE (sitelink=UPJ NGANTANG) ... ^ With query string: DECLARE mycursor BINARY CURSOR FOR SELECT "sitelink"::text,asbinary(force_collection(force_2d(the_geom)),'NDR'),gid::text from client WHERE (sitelink=UPJ NGANTANG) and (the_geom && setSRID( 'BOX3D(-168.293946139 335.281286999498,1831.65709314 1834.4621130005)'::BOX3D,find_srid('','client','the_geom') )) in C:\ms4w\apps\pattindo\htdocs\btspattindo.php on line 583

Edited by wardoyo
Link to comment
Share on other sites

What is $GLOBALS['map']? Is that a standard PHP class or is that a custom class? That's where the error is coming from, if you made that class yourself then you should look in the prepare_database method of the MapServer class to find the query where it's trying to declare the cursor. It looks like it's trying to use an identifier for the sitelink but it needs to be quoted or escaped somehow, the identifier has a space in it.I don't know what you mean by "mapfile", but did you write this PHP class that you're trying to use? The class definition is what contains the error.

Link to comment
Share on other sites

$GLOBALS["map"] is class of mapobject that contains function and member of mapobject but we must create the object first, for example:map=ms_newMapObj();i've solved the problem, i must add quote to variable $querystring like you've said :)i changed the script like this:$myquery=$oLayerString->queryByAttributes($qitem,$qitem."='$qstring'",MS_SINGLE);

Edited by wardoyo
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...