Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

mysterious server error

Posted on 2003-03-12
4
Medium Priority
?
158 Views
Last Modified: 2008-07-03
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!
0
Comment
Question by:server_room
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
VGR earned 60 total points
ID: 8123905
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
 
LVL 2

Expert Comment

by:Hatemben
ID: 8124290
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
 
LVL 15

Expert Comment

by:VGR
ID: 8126105
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
 
LVL 1

Author Comment

by:server_room
ID: 8133357
That's ok, it's running really great right now. But thanks anyway!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question