[Mapserver-users] Sending String Logical Expressions

James Vogl isjames at ci.high-point.nc.us
Wed Apr 2 10:45:47 EST 2003


Hi All,
The write-up PHPMapScriptMySQLShapeFiles for the mapserver-users forum was
instrumental in getting me started in PHP and Mapscipt. However, I've come
across a problem I haven't been able to solve.
	I have constructed a simple HTML web form in which users enter a SQL-like
formula into a single textbox. Using a simple GET form and submit button,
the single textbox value gets sent to a PHP file. The method works fine for
queries on numeric fields in which the user enters:

     [Block]= 500 and [I_o] = 1.

But Mapserver fails to return any results when a text field is specified
like so:

     '[Street_Nam]' = "MAIN"

or to avoid sending special characters:

     ‘[Street_nam]’="MAIN"

By using the echo command in the receiving PHP I'm able to confirm that the
proper string is being sent:

     echo "<br>The string sent is $qstring<br>";
In this case value returned is:
     The string sent is '[Street_Nam]’=\"MAIN\"

If I explicitly specify the value for setexpression as such:
     $qclass->setexpression("('[Street_Nam]' = \"MAIN\")");
the query works fine.
However, the following expression does not:
     $qclass->setexpression("(${qstring})");

I wonder if the problem may be a lack of clarity as to how PHP parses string
variables.




More information about the mapserver-users mailing list