Php batch updates the database, but it shows that the memory is insufficient and cannot be changed. Please submit the 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 ='' "; // Construct a query statement $ result_row = mysql_query ($ SQL); if (! $ Result_row) {die ("cocould not to the database
". 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); // execute update // unset ($ value );} echo "batch generation completed";} else {echo "generated ";}
Reply to discussion (solution)
While ($ row ){
....
}
Aren't you an endless loop?
While ($ row ){
....
}
Aren't you an endless loop?
How can I improve my skills? I hope you will not hesitate to give me some advice.
$ SQL = "select * from user_invite where invite ='' "; // Construct a query statement
$ Result_row = mysql_query ($ SQL );
If (! $ Result_row)
{
Die ("cocould 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); // execute the update
// Mysql_free_result ($ result );
}
Echo "batch generation completed ";
}
Unset ($ row );
} Else {
Echo "generated ";
}
After changing the end tag address, no error is reported, but the IDs obtained each time are the same.
Nobody...
While ($ row as $ k) try
While ($ row as $ k) try
I tried to report an error.
The younger brother posted a post for the first time .... Please do not sink ..
$ SQL = "select * from user_invite where invite ='' "; // Construct a query statement $ result_row = mysql_query ($ SQL); if (! $ Result_row) {die ("cocould not to the database
". 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); // execute update} echo "batch generation completed ";
$ SQL = "select * from user_invite where invite ='' "; // Construct a query statement $ result_row = mysql_query ($ SQL); if (! $ Result_row) {die ("cocould not to the database
". 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); // execute update} echo "batch generation completed ";
Thank you, Big Brother. thank you very much.