[Mapserver-users] Re: php mapserver interference - usage question..

Ed Martin edman007x at mac.com
Sat Dec 27 15:04:17 EST 2003


i think that your problem is you are trying to use the CGI mapserver, 
the main_init.html is not needed when using php mapcript, to use the 
php mapscript you right a php script that loads mapscript, loads the 
map file and then generates the maps and outputs the appropriate html, 
here is an example that is in the mapserver source

-------------------------
<HTML>

<BODY BGCOLOR="#CCCCCC">

<CENTER>

<H1>PHP/MapScript module test</H1>
<P>

<?php
//
// This example opens a regular MapServer .MAP file, renders the main
// Map image (with the default layers enabled), the legend and the
// scale bar, and displays them in the HTML output.
//

//
// Load MapScript module.
//
if (PHP_OS == "WINNT" || PHP_OS == "WIN32")
{
   dl("php3_mapscript.dll");
}
else
{
   dl("php_mapscript.so");
}

//
// Load MapServer .map file
//
// You can download the MapServer demo data from 
http://mapserver.gis.umn.edu/
//
$map = ms_newMapObj("demo.map");

// print $map->numlayers;
// phpinfo();

//
// RENDER MAIN MAP
//
// Note: If you get errors with the saveWebImage() call below, then 
make sure
// that the directory specified by IMAGEPATH in the .MAP file exists 
and is
// writable by the httpd user.
//
$img = $map->draw();

$url = $img->saveWebImage(MS_PNG, 0, 0, 0);
printf("<IMG SRC=%s WIDTH=%d HEIGHT=%d>\n", $url, $map->width, 
$map->height);

//
// LEGEND
//
$img = $map->drawLegend();
$url = $img->saveWebImage(MS_PNG, 0, 0, 0);
printf("<P><IMG SRC=%s>\n", $url);

//
// SCALE BAR
//
$img = $map->drawScaleBar();
$url = $img->saveWebImage(MS_PNG, 0, 0, 0);
printf("<P><IMG SRC=%s>\n", $url);

?>

</BODY>
</HTML>

-------------------------
when this page is accessed it will draw the maps, save them to wherever 
the mapfile says to, and then send the html to the browser to display 
everything, it never uses the main_init.html file


On Saturday, December 27, 2003, at 01:00  PM, 
mapserver-users-request at lists.gis.umn.edu wrote:

>
> Message: 2
> From: Horacio Samaniego <horacio at unm.edu>
> To: mapserver-users at lists.gis.umn.edu
> Organization: Dep. Biology, University of New Mexico
> Date: Fri, 26 Dec 2003 12:59:52 -0700
> Subject: [Mapserver-users] php mapserver interference -  usage 
> question..
>
> I've done some php coding but are new to the php/mapscript scheme...
>
> I've gone through all the available tutorials and examples, and
> everything looks fine. Although I'm still very confused about the
> reasons why I can't get both codes (php and html) on a same page...
>  I have done the following:
> modify the Itasca example to make sure that the system actually runs...
> But then I try to use php code in my page and it wont work... (off
> course that I've registered the extension in the httpd.conf and all 
> that
> stuff.... but still.)
>
> This makes me think that there is something special about the hidden
> variable that the main_init.html page sends to my main.php page where I
> try to insert the php code (just phpinfo actually) or something...
> (eventhough that a simple test.php with <html><?php phpinfo();?></html>
> works fine!)
>
> I'll appreciate if someone can put me back on the right track...
>
> and tell me how this thing works...
>
> Thanks so much and have a happy "turn" of the year...
>
>
> Horacio
>
>
>
>
>
> -- 
> Horacio Samaniego <horacio at unm.edu>
> Dep. Biology, University of New Mexico
>
>
> --__--__--
>




More information about the mapserver-users mailing list