[mapserver-users] php/sql quote problem

Twan Kogels twan at twansoft.com
Tue Dec 11 08:00:29 EST 2001


I'm try to add a point to the postgresql database, with php4. The following 
code is used:

====================
$conn = pg_pconnect ("host=10.0.0.2 port=5432 dbname=testdb user=postgres 
password=postgres");
$sql="insert into popplace_table (name, the_geom) values ('$stadnaam', 
'GeometryFromText('POINT($geox $geoy)', 312)')";
print "\n<!--- $sql -->\n";
$result = pg_Exec ($conn, $sql);
====================

But when i try to execute the query i get an error:
====================
<-- insert into popplace_table (name, the_geom) values ('twans stad', 
'GeometryFromText('POINT(-518308.59661667 1867193.233333)', 312)') -->
Warning: PostgreSQL query failed: ERROR: parser: parse error at or near 
"point" in /usr/local/apache/htdocs/mymap/mymap.phtml on line 165
====================

I suspect there is a problem with the quotes around "geometryfromtext". I 
tryed to escape them:

$sql="insert into popplace_table (name, the_geom) values ('$stadnaam', 
'GeometryFromText(\'POINT($geox $geoy)\', 312)')";
$sql="insert into popplace_table (name, the_geom) values ('$stadnaam', 
'GeometryFromText(''POINT($geox $geoy)'', 312)')";
$sql="insert into popplace_table (name, the_geom) values ('$stadnaam', 
'GeometryFromText(/'POINT($geox $geoy)/', 312)')";

But none of these work :( Has anybody got a idea what i'm doing wrong?

Thanks,
- twan

-- 
http://www.twansoft.com 




More information about the mapserver-users mailing list