Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 36 bytes) in E:\phpStudy\WWW\redis\update.php on line 12
$sql="select * from user_invite where invite=''";//构建查询语句$result_row=mysql_query($sql);if(!$result_row){die("could not to the database</br>".mysql_error());}$row=mysql_fetch_array($result_row,MYSQL_ASSOC);if($row){$arr=array(); while($row){ $arr[]=$row; } foreach($arr as $key=>$val) { $ids=$val['id']; //$sql="update user_invite set invite='' where invite!='' "; $sqls="update user_invite set invite='".make_coupon_card()."', addtime='".time()."' where invite='' and id='".$ids."' "; print_r($sqls); //exit; $result=mysql_query($sqls);//执行更新 //unset($value); } echo "已经批量生成完成"; }else{ echo "已经生成过了"; }
while($row){
....
}
你这不是死循环吗?
while($row){
....
}
你这不是死循环吗?
$sql="select * from user_invite where invite=''";//构建查询语句
$result_row=mysql_query($sql);
if(!$result_row)
{
die("could not to the database".mysql_error());
}
$row=mysql_fetch_array($result_row,MYSQL_ASSOC);
if($row){
$arr=array();
while(!empty($row)){
$arr[]=$row;
foreach($arr as $key=>$val)
{
$ids=$val['id'];
//$sql="update user_invite set invite='' where invite!='' ";
$sqls="update user_invite set invite='".make_coupon_card()."', addtime='".time()."' where invite='' and id='".$ids."' ";
print_r($sqls);
//exit;
$result=mysql_query($sqls);//执行更新
//mysql_free_result($result);
}
echo "已经批量生成完成";
}
unset($row);
}else{
echo "已经生成过了";
}
改了下结束标签地址,现在是不报错了,但是每次取出来的id都是一样的
没人吗。。。
while($row as $k) 试试
while($row as $k) 试试
小弟第一次发帖啊。。。。求别沉。。
$sql="select * from user_invite where invite=''";//构建查询语句$result_row=mysql_query($sql);if(!$result_row){ die("could not to the database</br>".mysql_error());}while($row=mysql_fetch_array($result_row,MYSQL_ASSOC)){ $ids=$row['id']; $sqls="update user_invite set invite='".make_coupon_card()."', addtime='".time()."' where invite='' and id='".$ids."' "; $result=mysql_query($sqls);//执行更新}echo "已经批量生成完成";
$sql="select * from user_invite where invite=''";//构建查询语句$result_row=mysql_query($sql);if(!$result_row){ die("could not to the database</br>".mysql_error());}while($row=mysql_fetch_array($result_row,MYSQL_ASSOC)){ $ids=$row['id']; $sqls="update user_invite set invite='".make_coupon_card()."', addtime='".time()."' where invite='' and id='".$ids."' "; $result=mysql_query($sqls);//执行更新}echo "已经批量生成完成";