[mapserver-users] php-dbase replace error

Shaik Anwar Hussain shussain at atsincorp.com
Mon Apr 8 12:02:43 PDT 2002


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



More information about the MapServer-users mailing list