mysterious server error

Hello,
This script below is giving me a wierd error whenever I run it I get a DNS error/server not found
And I was just browsing through other files in the same direcotry and all!

**************************************************************
records.php
<?php


include "textdb_v3.inc.php";
$dbClass->setWorkingDb("sic");

$userDb = $dbClass->getAllValidRecords();
$sic_count = count($userDb);


$data = "";
if(empty($mode))
{

$mode = "";

}

if($sic > $sic_count)
{
echo "Done!";
//exit;
}




if($mode == "records")
{
$contents = "";


$handle = opendir('./data_id/$sic');  
while (false!==($file = readdir($handle)))
{  
if ($file != "." && $file != ".." && !is_dir( "./data_id/$file"))
{
$array2[] = $file;
       
} else {

}
   


}

closedir($handle);


$f_count = count($array2);
$sic_rec = $dbClass->get($sic);


$file_id = eregi_replace(".htm", "", $array2["$f_id"]);
$dbClass->setWorkingDb("ac");
$ac_rec = $dbClass->get($file_id);
$tmp = explode(" ", "$ac_rec[val]");
$st = $tmp["2"];


$fd = fopen ("./data_id/$sic/$array2[$id]", "r");
$content = fread ($fd, filesize ("./data_id/$sic/$array2[$id]"));
fclose ($fd);

preg_match('/Selected Business Listings.*/is', $content, $matches);
$content = $matches[0];
preg_match_all('/<TD[^>]*>(.*)><\/TD>/U', $content, $matches);
foreach($matches[1] as $key=>$val)
{
    $res[$key] = tags(str_replace(" ","" , $val));
}

$i = 0;
$j = 0;
$first = true;
foreach($res as $val)
{
    if (ereg("$st",$val))
    {
         $citname = $val;
      list($city, $state) = split(' + +', $val);
         $data[$i][city] = $city;
         if (!$first)
         {
              continue;
         }
         $first = false;
    }
   
    $data[$i][city] = $city;
    $data[$i][state] = $state;

   
    if ($j == 1)
    {
         $data[$i][name] = $val;
    }
    if ($j == 2)
    {
         $data[$i][address] = $val;
    }
    if ($j == 3)
    {
         $data[$i][phone] = $val;
         $i++;
         $j = 0;
    }    
    $j ++;
}





for($i=0;$i<count($data);$i++)
{
$contents .= "\"$data[$i][name]\",\"$data[$i][address]\",\"$data[$i][city]\",\"$data[$i][state]\",\"$data[$i][phone]\"\n";
}



$fp = fopen($sic_rec[val].".csv","a+");
fputs($fp, $contents);


     if($f_id == $f_count)
     {

     $f_id = 0;
     $sic = $sic+1;

     $data .= "<meta http-equiv='refresh' content='0;URL=records.php?sic=$sic&sic_count=$sic_count&f_id=$f_id&f_count=$f_count&mode=records'>";

     } else {

     $f_id = $f_id+1;

     $data .= "<meta http-equiv='refresh' content='0;URL=records.php?sic=$sic&sic_count=$sic_count&f_id=$f_id&f_count=$f_count&mode=records'>";
     }





} else {

$dbClass->setWorkingDb("sic");
$sic_rec = $dbClass->get("1");



$handle = opendir('./data_id/1');  
while (false!==($file = readdir($handle)))
{  
if ($file != "." && $file != ".." && !is_dir( "./data_id/$file"))
{
$array2[] = $file;
       
} else {

}
   


}

closedir($handle);


$f_count = count($array2);
$f_id = 0;
$fp = fopen("$sic_rec[val].csv","a+");
fputs($fp, "\"name\",\"address\",\"city\",\"state\",\"phone\"\n");
$sic = 1;

$data .= "<meta http-equiv='refresh' content='2;URL=records.php?sic=1&sic_count=$sic_count&f_id=$f_id&f_count=$f_count&mode=records'>initializing....";



}



echo $data;



?>

**************************************************************

This site is great!
LVL 1
server_roomAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VGRCommented:
sorry, but when I see things like this, I stop analyzing the "code" and I switch to position "please write proper code" :D

while (false!==($file = readdir($handle)))

//should be :
while ($file = readdir($handle))

 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HatembenCommented:
don't worry for the DNS Error ... ;)))  just make your code proper as told ya VGR :))

and btw there is no tags() function in php, it's strip_tags() ;)
0
VGRCommented:
post here the pseudo-code of what is supposed to do the above script, we'll check it, and (time permitting) rewrite it "neat and fine"
0
server_roomAuthor Commented:
That's ok, it's running really great right now. But thanks anyway!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.