致命错误:在64行上超过30秒的最大执行时间
问题描述:
我想要做的是样式从sql中检索到的文本。但是,当我尝试预览它,我得到* 致命错误:最大执行时间30秒超过64行*。我试着把ini_set('max_execution_time',300);但仍然是同样的问题。这里是代码:致命错误:在64行上超过30秒的最大执行时间
<?php
ini_set('max_execution_time', 300);
$info="<h3>Τεχνικά Χαρακτηριστικά</h3>";
$sql_1 = mysql_query("SELECT * FROM info WHERE parent = '$id'")or trigger_error(mysql_error());
$counter = mysql_num_rows($sql_1);
if($counter > 0){
while ($row_1 = mysql_fetch_array($sql_1)){
$temp = $row_1['add_info'] ."</br>";
$temp = str_split($temp);
for($i=0; $i <= sizeof($temp); $i++){
if($temp[$i] == ":"){
break;
}
}
$temp_1="<strong>";
for($w=0; $w < sizeof($temp); $w++){
if($w < $i+1){
$temp_1 .= $temp[$w];
}else if($w = $i+1){
$temp_1 .="</strong>";
}else{//this is line 64
$temp_1 .= $temp[$w];
}
}
$info .= $temp_1 . "<br/>";
}
}
?>
答
你可能用线}else if($w = $i+1){
进入一个无限循环,更改到}else if($w == $i+1){
或}else if($w === $i+1){
。
btw。在每个循环执行sizeof()是非常糟糕的主意 - 只计算一次 – hamczu 2012-03-14 23:19:36
这是通常接受答案的部分。 – 2012-03-15 06:38:14