Question

I'm learning php MVC and in my display model i got this fatal error Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\kowab\app\models\display.php on line 36

line 36 is $data = mysql_fetch_array($sql);

Pas de solution correcte

Autres conseils

To remove this error you have to increase max_execution_time in your php.ini. Afterwards you have to restart the apache.

Or you add ini_set('max_execution_time', x) at the top of your script.

But you should think about optimizing your query and code first.

Are you watching from the Arabic man's tutorials? (Ali Hamdi)

I experienced the same thing and I made my else statement of the display class this way:

else
            {
                $num = mysql_num_rows($sql);
                while ($num > 0)
                    {
                        $data = mysql_fetch_array($sql);
                        $num--;
                    }
            }

        return $data;
    }

}

?>

It didn't solve the problem, but it brought back the form at least. So I continued watching the rest of the tutorials and following him so that later I address that part. I have written him and awaiting for his response. as soon as he does, I'll get back to you with the solution.

Up your execution time by making your first line of code:

set_time_limit($x);

$x should be the maximum time in seconds for running the script. A value of 0 will let the script run infinitely.

http://us1.php.net/set_time_limit

NOTE: It is weird that you hit a 30 second time limit on line 36, so you probably have a problem with your code that we can't identify, because you haven't posted it.

You can increase that time by looking for max_execution_time in php.ini but before that you need to know what cause this issue. Check your query there might be some loop or it returns a huge data

set_time_limit($seconds);

Per the docs. If you pass a value of 0 for $seconds there will be no time limit.

here is my model

// display

class display extends awebarts {

public function __construct($tablename) {


         $this->tablename= $tablename;

         $this->connectToDb();

         $this->getData();

         $this->close();



}

function getData() {

   $query = "SELECT * FROM $this->tablename ORDER BY `ID` DESC LIMIT 1";

   if(!$sql = mysql_query($query))
   {
   throw new Exception (mysql_error());
   }
   else {
      $num= mysql_num_rows($sql);
      while($num >0)
      {
      $data= mysql_fetch_array($sql);
      }
   }
          return $data;
}

}

?>``

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top