Hi all I have a function called dofile()

I seem to have a problem where I need the function to stop and then restart after the 
mysql_error() is true and the renaming is done.
otherswise in the php file I have to execute is like so:
dofile(args);
dofile(args);
dofile(args);

this is a few times;

If someone knows of an elegant why to perfect this, that would be most appreciated.
Kind Regards
Brent Clark

================================================================

if(is_dir($batch_dir)){
        $fd = opendir($batch_dir);
        while(($part = readdir($fd)) == True){
                clearstatcache();
                //if($part != "." && $part != ".." && (substr($part,0,3) == 
$begin_number) && (strlen($part) >= 8)){
                if($part != "." && $part != ".." && (strlen($part) >= 8)){

                        $d_array[] = $part;
                                }
                        }
                }else{
                return "OOPS";
        }
        if($fd == True){
        closedir($fd);
        }

if(! is_dir($processed_dir."/".$time)){
        mkdir($processed_dir."/".$time, 0777);
}

if(count($d_array) >= 1){
foreach($d_array as $fname=>$fvar){
$bcode = substr($fvar,0,-4);
$sql="INSERT INTO Barcodes (barcode, month, filename) VALUES 
('$bcode','$time','$fvar')";
mysql_query($sql);
        if(mysql_error()){
                        if(strstr($var,"-")){                                          
                                  <=== Problem starts here
                                                        $value = substr($fvar,9,-4);
                                                        $prefile=substr($fvar,9);
                                $value++;
                                rename($batch_dir."/".$fvar, 
$batch_dir."/".$prefile-$value.".pdf");
                                $redo=true;

                                //$newvalue = substr_replace($fvar,$value,-5);
                                //rename($batch_dir."/".$fvar, 
$batch_dir."/".$newvalue.".pdf");
                        }else{

                                        $file=substr($fvar,-5);
                                        rename($batch_dir."/".$fvar, 
$batch_dir."/".$file."-1.pdf");
                        }

        }else{
                        rename($batch_dir."/".$fvar, 
$processed_dir."/".$time."/".$fvar);
                        }
                }
        }

Reply via email to