Link to home
Start Free TrialLog in
Avatar of server_room
server_roomFlag for United States of America

asked on

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!
ASKER CERTIFIED SOLUTION
Avatar of VGR
VGR

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Hatemben
Hatemben

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() ;)
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"
Avatar of server_room

ASKER

That's ok, it's running really great right now. But thanks anyway!