[UMN_MAPSERVER-USERS] mapserver, jbox and php (but not mapscript)

Bill Binko bill at BINKO.NET
Sun Apr 10 13:44:54 EDT 2005


On Sat, 9 Apr 2005, Richard Greenwood wrote:

> kallwn <kallwn <at> ICIRCUS.NET> writes:
>
> > The only thing left that I can think
> > of is that somehow that by calling the mapserver cgi it is causing the
> > PHP code not to connect to the database and populate the list box. I
>
> The mapserver CGI can not call or run PHP on that page. When you make a request
> to a web server it passes a request for dynamic content on to the appropriate
> application, mapserver CGI OR PHP (or ASP, or Python, or whatever). That
> application does its thing and passes a page back to the web server, which in
> turn passes the page back to you. But mapserver can not call the PHP process, or
> any other process on the server. Point is, only one server side process can be
> called per page. (jBox is a client side process).

This is true...technically, if you're using Apache, you can get things
daisy-chain, but it's not worth the effort.

> If you can convert your MySQL data into a shape file that would probably be
> easiset. Mapserver has some support for connecting to MySQL, but I have not
> experience with it (search the list archives). Or you could convert your app to
> Mapscript.

Another easy solution is to simply "double-pump" the request.  That is,
your template file does nothing but set some variables and do a refresh to
your PHP page.  I have used that well.  Lets say you need to send an ID
(parcel ID n my case) to a dynamic PHP script.  You setup something like
'parcel_id' to be the variable you want and just write a template that
does the refresh:

<html>
<head>
<meta http-equiv="REFRESH" content="0; URL='http://myserver.example.com/myPhpScript.php?id=[parcel_id]'">
</head>
<body>
<p>
        If you are not automatically redirected, you can access
        <a href="http://myserver.example.com/myPhpScript.php?id=[parcel_id]">
           Your Information by clicking on this link</a>.
</p>
</body>
</html>


That way, you can do all your logic in PHP (in the myPhpScript.php page).
Of course, if you're sending lots of information, that URL= parameter can
get pretty ugly.

You also want to make sure you have the "0; " before the url since that
the silly format.  The 0 says how long to wait.

I also always include the link in the BODY section so that people who
diable meta-refreshes have a way to get at your information.

Hope this helps.
Bill



More information about the mapserver-users mailing list