[mapserver-users] drawing layer with user names from mysql table

Jan Mantkowski jan.mantkowski at gmx.de
Wed Mar 20 03:24:19 EST 2002


Hi all,

i have not been able to make my script run right now.
Please help me.

Jan

PS:
If someone has a complete working example of how to display data from mysql
table as a layer of a map please mail it to me.

I always get this error:
Fatal error: Call to a member function on a non-object in
c:\apache\htdocs\pn_71\html\modules\map\index-standalone3.php on line 28

line 28 is: $layer =  $map->getLayerByName( $layerName );

This is my data in the mysql table:

-0.1271    51.5063    Jan London
-3.7057    40.4203    Jose Madrid
2.3453    48.8547    Madeleine Paris
9.9898    53.5548    Fritz Hamburg

This my php script:

<?php

// load .dll`s, so there is no need to edit the php.ini.
// but you need to put this files in your /php/extensions folder

dl("php_mapscript_35.dll");
dl("php_proj.dll");
dl("php_dbase.dll");

//variables

GLOBAL $map;
GLOBAL $image;
GLOBAL $layer;
$layerName="PNUsers";

//mysql_q
$db = mysql_connect("localhost", "root", "");
mysql_select_db("Rogue",$db);
$results = mysql_query("SELECT * FROM nuke_map",$db);
if ($results === false) die("failed");
//display result of mysql query on screen
while ($show = mysql_fetch_array($results, MYSQL_ASSOC)) {
echo
$show["pn_lon"]."&nbsp;&nbsp;&nbsp;&nbsp;".$show["pn_lat"]."&nbsp;&nbsp;&nbs
p;&nbsp;".$show["pn_name"]."<br>\n";
}

//drawPoints
$layer =  $map->getLayerByName( $layerName );

   // Loop through result of point query and:
   while ($line = mysql_fetch_array($results, MYSQL_ASSOC)) {
                 $pt = ms_newPointObj();
                 $pt->setXY( $line["pn_lon"], $line["pn_lat"] );

                 $pt->draw($map, $layer, $image, 0, "TEST");
                 $layer->set('status', MS_ON);
                 $layer->draw($image);
         }

//showmap
$map = ms_newMapObj("data/europe.map");
$image=$map->draw();
//$layer->draw($image);
$image_url=$image->saveWebImage(MS_PNG,1,1,0);
echo "<img src=\"".$image_url."\">";
?>


Thanks,

Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: europe.map
Type: application/octet-stream
Size: 879 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/mapserver-users/attachments/20020320/cd099c13/europe.obj


More information about the mapserver-users mailing list