[mapserver-users] php-dbase replace error

Jeff McKenna mckenna at dmsolutions.ca
Mon Apr 8 15:47:39 EDT 2002


Hello,

There is a known bug in the php4.0.6 dbase_replace_record function.  It
has been fixed in php4.1.2, and you can get a phpmapscript dll for that
version on our site at:

http://www2.dmsolutions.on.ca/mapserver/dl/php4.1.2_php_mapscript_36-dev_libwww.zip


Jeff




Shaik Anwar Hussain wrote:
> 
> Hello List,
> 
>             I am trying to replace the dbase records using php_mapscript.
> Here is my php code. Its rewriting the records with null values. i want to
> replace with different values. does any one can help me whats wrong in my
> code.
> 
>  Where photo is my shapefile name, it has 4 fields. i am using php4.06,
> mapserver3.5, apache,windows 2000.
> 
> <?php
> 
>         dl('php_mapscript.dll');
>         dl("php_dbase.dll");
>         dl("php_proj.dll");
> 
>    function delete_photo($shpfname, $pamcode)
>     {
>         $shapef = ms_newShapefileObj($shpfname,-2);
>                 $dbfile = dbase_open($shpfname, 2);
> 
>                 $numrec = dbase_numrecords($dbfile);
>                 $nf = dbase_numfields($dbfile);
> 
>              echo $numrec,"  ",$nf,$pamcode,"<BR>";
> 
>                 $pamscode = "1";
> 
>             for($k=0; $k<$numrec; $k++)
>                 {
>                    $rec = dbase_get_record($dbfile,$k);
> 
>                //echo $rec[0],$rec[1],$rec[2],$rec[3],"<BR>";
> 
>                    if (strtoupper(trim($rec[2])) == strtoupper($pamcode) )
>                    {
>                            $f1 = $rec[0];
>                            $f2 = $rec[1];
>                            $f3 = $rec[3];
>                        //echo $f1,$f2,"<br>",$rec[0].$rec[1].$rec[2]."<br>";
>                     dbase_replace_record($dbfile,
> array($f1,$f2,$pamscode,$f3),$k);
>                }
> 
>              }
> 
>              $shapef->free();
>          dbase_close($dbfile);
> 
>        }  // End of the function photo delete
> 
> # Begining of main program
> 
>     $shpfname1 = "E:/Program Files/Apache
> Group/Apache/htdocs/php406/data/photo";
>     $num='170A';
> 
>     delete_photo($shpfname1,$num);
> 
>     exit;
> ?>
> 
> Thanks,
> Anwar
> www.atsincorp.com


-- 

Jeff McKenna
GIS Specialist
DM Solutions Group Inc.
http://www.dmsolutions.ca/



More information about the mapserver-users mailing list