2012-09-25 48 views
1

我正在使用此腳本(更新https://gist.github.com/3763701),它很好地工作(恭喜作者),但'參數'選項不適用於我的表格這一呼籲:postgis_geojson.php腳本中的'參數'選項

http://localhost/postgis_geojson.php?geotable=seafloor_thermometry_point_wgs84&geomfield=geom&parameters=source='GEOMAR' 

給出:

There was an error parsing the JSON document. The document may not be well-formed. 
Document contents: 
<br /> <b>Warning</b>: pg_query() [<a href='function.pg-query'>function.pg-query</a>]: Query failed: ERROR: syntax error at or near &quot;GEOMAR&quot; at character 110 in <b>/var/www/html/postgis_geojson.php</b> on line <b>85</b><br /> An SQL error occured. 

然而,在PostGIS的這一呼籲:

select id,fid,source from seafloor_thermometry_point_wgs84 where source='GEOMAR'; 

給:

id | fid | source 
----+-----+-------- 
    1 | 1 | GEOMAR 
    2 | 2 | GEOMAR 
    3 | 3 | GEOMAR 
    4 | 4 | GEOMAR 
...etc 

哪裏能問題是什麼?

感謝這個任何暗示,

格里

編輯:

我的PostGIS表在ID PK,我使用了PostGIS 1.5和PostgreSQL 8.4.8,PHP-5.1。 6-27.el5,php-pgsql-5.1.6-27.el5,apache 2(httpd-2.2.3-43.el5)和rhel5中的Firefox 6.0.2 32位,

回答

1

解決方案:

在第70行,嘗試更改pg_escape_str ($參數)只需$參數