Re: [PHP3] max timeout error From: Alfred Perlstein (bright <email protected>)
Date: 04/30/00

* Mike Sears <neutrino <email protected>> [000429 19:24] wrote:
> Working on a script to read and grab information by use of a form from my
> httpd.conf file, but for some reason I keep getting a "Fatal error: Maximum
> execution time of 30 seconds exceeded in /etc/httpd/conf/httpd.conf on line
> 10" I'm not sure what it is doing here and how to go about fixing it.
>
>
>
> <?
>
> $httpd = "/etc/httpd/conf/httpd.conf";
>
> //open file in readonly mode
> $fp = fopen($httpd, "r");
>
> //EOF while statement
>
> while (!feof($fp));
> {
> //read line
> $line = fgets($fp, 1024);
>
> //check to see if there is a servername here
>
> if(eregi("^[[:space:][^#]]*$sub", $line)) {
> print "$sub is taken try again";
> } else {
> continue;
> }
> fclose($fp);
> }
>
> print "<form>";
> print "new";
> print "<input type=hidden name=insert value=1>";
> print "user <input type=text name=sub><br>";
> print "<input type=submit>";
> print "</form>";
>
> ?>

Please do not use the "reply" option of your mailer to send email to
the list, people with mailers that do threading (linking replies)
will not see this as a "new question" and you're more likely not
to get an answer from someone.

That said, the major problem I see here is that your fopen()
may have failed and I'm not sure feof($fp) when $fp doesn't
reference an open file is defined, you need to check the return
value for your open.

 $httpd = "/etc/httpd/conf/httpd.conf";

 //open file in readonly mode
 if(!($fp = fopen($httpd, "r")) {
    print "some error";
    exit;
 }

Also, your while loop is pretty convoluted, this is a bit clearer:

         while ($line = fgets($fp, 1024));
         {
               //check to see if there is a servername here
               if(eregi("^[[:space:][^#]]*$sub", $line)) {
                   print "$sub is taken try again";
               }
         }
         fclose($fp); // fclose outside of the loop where it belongs.

good luck,

-- 
-Alfred Perlstein - [bright <email protected>|alfred <email protected>]
"I have the heart of a child; I keep it in a jar on my desk."

-- PHP 3 Mailing List <http://www.php.net/> To unsubscribe, send an empty message to php3-unsubscribe <email protected> To subscribe to the digest, e-mail: php3-digest-subscribe <email protected> To search the mailing list archive, go to: http://www.php.net/mailsearch.php3 To contact the list administrators, e-mail: php-list-admin <email protected>