server_room
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("si c");
$userDb = $dbClass->getAllValidRecor ds();
$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]\",\"$da ta[$i][add ress]\",\" $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_i d&f_count= $f_count&m ode=record s'>";
} 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_i d&f_count= $f_count&m ode=record s'>";
}
} else {
$dbClass->setWorkingDb("si c");
$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\",\"ci ty\",\"sta te\",\"pho ne\"\n");
$sic = 1;
$data .= "<meta http-equiv='refresh' content='2;URL=records.php ?sic=1&sic _count=$si c_count&f_ id=$f_id&f _count=$f_ count&mode =records'> initializi ng....";
}
echo $data;
?>
************************** ********** ********** ********** ******
This site is great!
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("si
$userDb = $dbClass->getAllValidRecor
$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[$
$content = fread ($fd, filesize ("./data_id/$sic/$array2[$
fclose ($fd);
preg_match('/Selected Business Listings.*/is', $content, $matches);
$content = $matches[0];
preg_match_all('/<TD[^>]*>
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);$
{
$contents .= "\"$data[$i][name]\",\"$da
}
$fp = fopen($sic_rec[val].".csv"
fputs($fp, $contents);
if($f_id == $f_count)
{
$f_id = 0;
$sic = $sic+1;
$data .= "<meta http-equiv='refresh' content='0;URL=records.php
} else {
$f_id = $f_id+1;
$data .= "<meta http-equiv='refresh' content='0;URL=records.php
}
} else {
$dbClass->setWorkingDb("si
$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",
fputs($fp, "\"name\",\"address\",\"ci
$sic = 1;
$data .= "<meta http-equiv='refresh' content='2;URL=records.php
}
echo $data;
?>
**************************
This site is great!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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"
ASKER
That's ok, it's running really great right now. But thanks anyway!
and btw there is no tags() function in php, it's strip_tags() ;)