PHP Mapscript connection to PostGIS

Sean Grimland skgstyle at YAHOO.COM
Wed Nov 8 09:21:54 PST 2006


Hello List,

Can someone please tell me what I am doing wrong in
the below code.  I cannot connect to a PostGIS
database, I get ths error - 
msPOSTGISLayerOpen(): Query error. couldnt make
connection to DB with connect string 'Resource id #2'.

Error reported was 'missing "=" after "Resource" in
connection info string
'.

$db_handle = pg_connect("user=* dbname=* host=*
password=* port=5432")
   or die('Could not connect: ' . pg_last_error());

$admin = ms_newLayerObj($oMap);
$admin->set( "name", "admin" );
$admin->set( "type", MS_LAYER_POLYGON);
$admin->set( "connectiontype", MS_POSTGIS );
$admin->set( "connection", $db_handle );
$admin->set( "status", MS_ON) ;
$admin->set( "data", "the_geom from
cadastre.world_admin_2002" );

I've tried this too with no luck - 

//$admin->set( "data", "the_geom from ( select * from
cadastre.world_admin_2002 ) as foo using unique gid
using SRID=4326" );


$oImage = $oMap->draw();
$url = $oImage->saveImage($img_path.$image_name);


I am using ms4w2.2 with PHP 5, Postgresql 8.1

Thanks in advance!

Sean Grimland





 
____________________________________________________________________________________
Sponsored Link

Mortgage rates near 39yr lows. $420k for $1,399/mo. 
Calculate new payment!
http://www.LowerMyBills.com/lre



More information about the MapServer-users mailing list