我的PHP编码遇到了一个奇怪的问题......让我来描述我的PHP代码的目的
代码完美正常但是当Excel行大小很大时,Point 1,2,3正在工作,但是4,5没有显示
没有错误没有警告......
我为什么会发生这个问题一无所知
我正在附上以下代码段:
<?php
error_reporting (E_ALL ^ E_NOTICE);
error_reporting (E_ALL ^ E_DEPRECATED);
error_reporting(0);
session_start();
require_once("index11.php");
require_once("simple_html_dom.php");
include('ganon.php');
ini_set('max_execution_time', 1200);
$val2 = $_SESSION['$val2'];
if($_SESSION['$val8'] == "mu")
{
if($_SESSION['$val2'] == "fr")
{
//echo "MU for FR";
$conn = mysql_connect("localhost", "root", "****");
if (!$conn) {
echo "Unable to connect to DB: " . mysql_error();
exit;
}
if (!mysql_select_db("DB")) {
echo "Unable to select mydbname: " . mysql_error();
exit;
}
$sql = "SELECT DISTINCT EANcode from test WHERE timestamp = DATE( NOW( ) ) and EAncode <> ''";
$result = mysql_query($sql);
$a = 0;
while ($row = mysql_fetch_assoc($result)) {
foreach ($row as $b)
{
$ean = $b;
$url = "WWW.URL.COM" .$ean;
$html = file_get_html($url);
$link=$html->find('a[class=webtrekk]');
$link1 = $link[4] -> href;
$link2 = "WWW.URL.COM" .$link1;
$html = file_get_dom($link2);
$i = 0;
foreach($html('tr') as $rowdata) {
$name = '';
$test1 = '';
foreach($rowdata('a[class="test1"]') as $d) {
$name = $d('img', 0)->alt;
$name2 = mysql_real_escape_string($name);
$arr = explode("-", $name2, 2);
$name1 = $arr[0];
}
foreach($rowdata('td[class="test1"]') as $d) {
foreach($d('span[class="test1"]') as $d2) {
$test1 = $d2->getPlainText();
}
}
if(!$test1 == "")
{
$i = $i + 1;
$now = new DateTime();
$dt = $now->format('Y-m-d H:i:s');
mysql_select_db("DB", $conn);
$sql = "INSERT INTO `DB`.`tab_fr` (`pos`, `ean`, `prod_url`, `prod_compttr`, `prod_test1`, `timestamp`) VALUES ('$i', '$ean','$link2','$name1','$test1', '$dt')";
mysql_query($sql) or die('Error, insert query failed' . mysql_error());
}
}
}
}
flush();
usleep(300000);
$msg = "Query op Test.fr succesvol afgerond";
echo $msg ."<br/>" ;
}
if($_SESSION['$val2'] == "fr")
{
$v2 = "Test.fr,";
}
else
{
$v2 = "";
}
if($_SESSION['$val2'] == "fr")
{
echo "<a href=10d2.php>cLICK HERE ".$v2."</a>" ."<br/>";
}
}
?>
这是因为代码中遇到超时问题,任何人都可以帮助我在超时后继续编码。
答案 0 :(得分:0)
当处理大量数据时,可能会导致等效于无限循环的情况。您看到数据插入在数据库中是成功的,但尚未完成。所以你必须找到一个技巧来避免这种无限循环执行。
提示:将整个循环分成3或2。