此腳本崩潰apache。我故意刪除了網址。任何人都可以看看並提供替代品嗎?謝謝!php腳本崩潰apache
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script language="javascript">
$(document).ready(function()
{
$("#btn_Start").attr("disabled",false);
setTimeout(function(){Doextract();},2000);
});
function Doextract()
{
if($("#stop").val() == "1")
{
$("#btn_Start").attr("disabled",true);
window.location.reload();
}
}
function stop()
{
if($("#stop").val() == "1")
{
$("#stop").val("0");
$("#btn_Start").val("Start");
}
else
{
$("#stop").val("1");
$("#btn_Start").val("Stop");
$("#btn_Start").attr("disabled",true);
window.location.reload();
}
}
</script>
</head>
<body>
<input type="hidden" value="1" id="stop" />
<input type="button" value="Get citys" id="btn_Start" onclick="stop();" /></div>
<div id="showResult"></div>
<?php
set_time_limit(0);
ini_set('memory_limit', '-1');
$url = "";
include_once 'simple_html_dom.php';
include_once 'conn.php';
$id = $_GET['id'];
$sql = "select * from page_category where category_tag = 0 and city_id = '".$id."' LIMIT 0 , 1";
$rst = mysql_query("$sql",$link);
if($rst > 0)
{
$details = mysql_fetch_row($rst);
$cateid = $details[0];
$count = mysql_num_rows($rst);
$html = file_get_html($url.$details[3]);
$sql = "delete from page_data where category_id =".$cateid;
$rst = mysql_query("$sql",$link);
foreach ($html->find('input#search-find') as $e)
{
$categoryname = $e->value;
}
foreach ($html->find('div#toolbar-top') as $e)
{
foreach ($e->find('strong') as $c)
{
$temp = split('b',$c->plaintext);
$total = $temp[0];
$pages = $total/25;
//echo $total."<br>";
//echo $pages;
}
}
$j = 1;
//echo $pages;
for($i=1;$i<=ceil($pages);$i+1)
{
$urls = $url.$details[3]."?page=".$i;
//echo $urls;
$html = file_get_html($urls);
foreach ($html->find('div.description') as $e)
{
$name = "";
foreach ($e->find('h2') as $c)
{
$name = $c->plaintext;
}
$address = "";
foreach ($e->find('span.street-address') as $c)
{
$address = $c->plaintext;
}
$locality ="";
foreach ($e->find('span.locality') as $c)
{
$locality = $c->plaintext;
}
$region ="";
foreach ($e->find('span.region') as $c)
{
$region = $c->plaintext;
}
$code ="";
foreach ($e->find('span.postal-code') as $c)
{
$code = $c->plaintext;
}
$tel ="";
foreach ($e->find('li.number') as $c)
{
$tel = str_replace('(','',$c->plaintext);
$tel1 = str_replace(')','',$tel);
$tel2 = str_replace('-','',$tel1);
$tel3 = str_replace(' ','',$tel2);
}
$email = "";
foreach ($e->find('a.email') as $c)
{
$email = str_replace('mailto:','',$c->href);
}
$sql="insert into page_data (category_id,name,category,address,city,state,postalcode,telnumber,email) values ";
$sql.="(".$cateid.",'".$name."','".$categoryname."','".$address."','".$locality."','".$region."','".$code."','".$tel3."','".$email."')";
//echo $sql;
$res = mysql_query("$sql",$link);
}
}
$sql = "update page_category set category_tag = 1 where id ='".$cateid."'";
//echo $sql;
$res = mysql_query("$sql",$link) or die(mysql_error());
echo "Category: \"".$details[2]."\" is done!";
}
else
{
echo "All categories are done!";
//$sql = "update page_city set city_tag = 2 where id =".$id;
//$rst = mysql_query("$sql",$link);
}
?>
</body>
</html>
檢查您的文章的格式。閱讀有點困難,特別是單行註釋。 – 2010-01-13 20:45:20
解釋你的意思是「崩潰」。並修復格式。 – 2010-01-13 20:45:38
如果我是你,我會開始修復標記,並提供一些關於錯誤的更多信息。一些錯誤日誌,如果你能也幫助。 – Juan 2010-01-13 20:45:54