This script crashes apache. I removed url on purpose. Can anyone take a look and offer alternatives? Thanks!
<?php
set_time_limit(0);
ini_set('memory_limit', '-1');
$url = "http://www.yellowpages.com";
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;
$rst = mysql_query("$sql",$link);
?>
<!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=utf-8" />
<title>export data</title>
<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 ()
{
$("#loading").hide();
var number = $("#number").val();
for(var i = 1; i<= number; i++)
{
var category = $('#url_'+i).html();
var categoryid = $('#id_'+i).val();
getdata(category,categoryid);
}
});
function getdata(category,id)
{
$.ajax({
url:'do.php?category='+category+'&id='+id,
type:'post',
dataType:'text',
success:update_page
});
}
function update_page()
{
}
</script>
<style type="text/css">
<!--
#loading{
position:absolute;
width:300px;
top:300px;
left:50%;
color:red;
height:60px;
background-color:yellow;
margin-left:-150px;
text-align:center;
padding:7px 0 0 0;
font:bold 15px Arial, Helvetica, sans-serif;
z-index:9999;
}
-->
</style>
</head>
<div id="loading">Init data, please wait...</div>
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<th>#</th><th>Name</th><th>category</th>
</tr>
<?php
if($rst > 0)
{
$details = mysql_fetch_row($rst);
$count = mysql_num_rows($rst);
}
if($count == 0)
{
echo "It is done!";
$sql = "update page_city set city_tag = 2 where id =".$id;
$rst = mysql_query("$sql",$link);
}
else
{
$i = 1;
do
{
$category=$details[3];
echo "<tr><td>".$i."</td><td>".$details[2]."</td>";
echo "<input type=\"hidden\" id='id_".$i."' value=\"".$details[0]."\" />";
echo "<td id='url_".$i."'>".$details[3]."</td></tr>";
$i++;
}
while ($details = mysql_fetch_row($rst));
}
?>
</table>
<input type="hidden" name="number" value="<?php echo $i ?>" id="number" />
<body>
</body>
</html>