Hello FRIENDS, I have problem with program output in php. What is my program is Input Values - A LENGTHY CALCULATION - OUTPUT I have to put values 10000 times. But php does not work after 3 or 4 values. Can somebody help me how can i control memory of php? and is it possible after putting 1 value program wait for output. and after output it take value after few moment? Does php buffer help? Plz i need a urgent help regarding this. Thanks
why wouldnt your script out put multiple values? .. or do you mean processes involved and you dont want to hit the button everytime to submit it? It doesnt make sense .. because after your first value is submitted, why cant your PHP script use that to complete all the variables/ values? If you need somethin without page reload, use PHP and Ajax
I donnot have much knowledge about ajax.. See, what exactly happen <?php $var = {Array has five hundred values} // extracted from database $title = {Array title of five hundred values} // extracted from database $count = count($var); for{$j=0;$j<$count;$j++) { $output_val = lengthy_function_calculation($var[$j]); } lengthy_function_calculation($id) { Length Calculation; return output; } ?> Now program get interrupt after 3 or 5 values passes. How to control the process, What is simple forumla in ajax? Definitely the process is very length, It should output immediately once get value from function. And seem like live program or buffering.
If you are extracting the values from a database, why are you even using an array? Why don't you just get the mysql result and loop through it, doing the calculation for each result?
Problem is not with array, I can process is without storing it in array. Problem is with function i am using. Function have a large calculation then some output. This calculation i have to use for several inputs, more than 5000 times. Thats why i am using for loop. But program get busy after 3-4 variable output.
You can use php function get_memory_usage() to control memory from inside the script. Also you can change memory_limit and max_input_time in php.ini Alternative to max_input_time in php.ini is a set_time_limit() function. I would recommend to check you have a memory leak in your calculation function. One of the most popular leaks is using callback function dynamically created in the loop - it is not freed when it's created with create_function. Купить магазин в Киеве Продать магазин в Киеве Ðрендовать магазин в Киеве Сдать магазин в Киеве
It is not clear what's happening: is your script terminated, going into inifinite loop, etc. Insert error_reporting(E_ALL); PHP: at the beginning and see the errors/warnings it produces. If there is a fatal error "Maximum execution time of XX second exceeded", use the set_time_limit function to increase allowed execution time.