Hi,
Anyone knows what does ' Fatal error: Maximum execution time of 30 seconds exceeded...' means?
Thanks.
*^^*
Printable View
Hi,
Anyone knows what does ' Fatal error: Maximum execution time of 30 seconds exceeded...' means?
Thanks.
*^^*
it means your script took more than 30 seconds to execute (the default maximum time limit for a script to execute), and PHP ended it so that it wouldn't sit there hogging resources.
you either have tons of things going on, or more likely, you have an infinite loop. you can solve this problem by optimizing your code and making sure you have no infinite loops, or if you must, you can use the function set_time_out() to turn off the time limit for your script. you can do that using the following line of code:
PHP Code:<?php
set_time_limit(0);
?>
Actually i am not very sure where does the problem lies in the php coding. This is because i am assigned to work on project done by previous student, and i am totally new to php.
The entire program, the php codings are too much...
Everytime i try to run the program the same fatal error will point to different line of different page...
What should i do?
T-T
you can try posting some of the code around the lines that are causing the error and I can try to help you point out some of the errors and stuff.. otherwise, you'll have to look through and debug each page, I guess. if you don't understand it, then you'll have to learn more about it, or (since you said something about student) ask for help from your instructor and/or peers. if possible, ask the student who originally wrote it for help.
The part of the error are as below, in bold:
I would like to ask the student who 1st did this project as well but sad to say, he has graduated from the school...Code:while(true)
{
$tmpecho = fgets ($fp, 1024);
//break from the loop
if(strstr($tmpecho,"Building configuration..."))
{
break;
}
}
T-T
okay, soo.. seeing as how this is creating an infinite loop, it basically means that either the file you're opening (defined as $fp) is too big to loop through, or the string you're searching for ("Building configuration...") is never found. you could try to make sure the file you're opening has that text in it and that it isn't too large.
also, since the script is only searching for if the string exists within that variable, your script would be faster and use less resources if you used strpos() instead of strstr(): (this also might solve all of your problems, because if your file is big and strstr() takes a while to execute, it might be causing the timeout.. although, judging from the code you gave me, I would guess that this is NOT the case, but you never know):
so.. verify that the file you're looking to open (you can find the filename by searching for where $fp is defined) has the "Building configuration..." string in it, and also make sure the file size isn't too large. I'm not completely sure how big a file would have to be to cause PHP to execute for 30 seconds, but I'll guess over 20mb or so.. also, don't forget to change the line that calls strstr() to the new line I posted above, and see what that does for you.PHP Code:while(true)
{
$tmpecho = fgets ($fp, 1024);
//break from the loop
if(strpos($tmpecho,"Building configuration...") !== false)
{
break;
}
}
Rewrite that loop like so:
This breaks the loop if the file is bad or simply reached the end.PHP Code:$found = false;
$fp = fopen(...);
while($fp && ($tmpecho = fgets($fp, 1024))) {
if(strpos($tmpecho, "Building configuration...") !== false) {
$found = true;
break;
}
}