Please help me out, i am facing this following error:

Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\timetable\exceldownload.php on line 172

How to rectify this error?

Recommended Answers

All 10 Replies

You need to modify your php.ini file to increase the max_execution_time setting to a value higher than 60 seconds.

Or...streamline your code if possible to perform the work in under 60 seconds, if possible that is.

commented: yes +5

I tried changing in php.ini file. But i am getting the same error

After changing the max_execution_time in php.ini save and restart your XAMPP. Then Run your file

You can also use set_time_limit(0) in your php file, so it runs indefinitely. Only use this very carefully. If possible, avoid it at all cost. Is there no way to streamline your process ?

Pritaeas is right. If you're in a shared hosting environment, you can change the timeout that way, however, you will never get the script to run forever in a shared hosting environment.

Shared hosting setups are done in a way that forbids your script from running for a defined period of time (usually between 60 to 300 seconds), you will not be able to control that or get around it without using a dedicated or virtual dedicated server. They do this to stop a user from writing inefficient code, keep user from taking all system resources, and to ensure that a customer does not hinder the service level requirements for other customers.

If using set_time_limit() does not fix the issue, and you're in a shared hosting environment, then there's little to nothing the you'll be able to do without streamlining your code.

now, i set set_time_limit(500)...and now i am not facing this error. its working. Can you tell me clearly whats the advantage and disadvantage in using "set_time_limit(500)", please. Did my server gets slowed? This page will be used by nearly 50 persons a day....did my server gets affected. Please tell me

Well, the bigger question is what is trying to be done on line 172 of your code? It may be inefficient code and by making it more efficient you don't need to worry about the ramifications of using such a high execution time.

Aside for the possibility that it will slow your overall computer down, or that more RAM will be used because 20+ users will be running the same process that's on line 172 of your code or other issue.

Therefore, what exactly is being done on line 172? Maybe we can help you optimize your code so you don't have to change PHP-wide settings for one function's slow process.

Is he trying to download excel files from clients? If so, is there a way to exclude the time to download the file from php code running time?

Is he trying to download excel files from clients? If so, is there a way to exclude the time to download the file from php code running time?


Create a symbolic link to the actual file and make the download link point at the symbolic link. Then, when the user clicks on the DL link, they'll get a file download from the real file but named from the symbolic link. It takes milliseconds to create the symbolic link and is better than trying to copy the file to a new name and download from there.

For example:


// validation code here

$realFile = "Hidden_Zip_File.zip";
$id = "UserID1234";

if ($_COOKIE['authvalid'] == "true") {
    $newFile = sprintf("myzipfile_%s.zip", $id); //creates: myzipfile_UserID1234.zip

    system(sprintf('ln -s %s %s', $realFile, $newFile), $retval);

    if ($retval != 0) {
        die("Error getting download file.");

    $dlLink = "/downloads/hiddenfiles/".$newFile;

// rest of code


<a href="<?php echo $dlLink; ?>">Download File</a>

That's what I did when I used Go Daddy because Go Daddy kills the script from running after 2 minutes 30 seconds or so....this prevents that problem and hides the actual file.

You can then setup a CRON job to delete the symbolic links at regular intervals....

This whole process will then send the file to the browser and it doesn't matter how long it runs since it's not a script.

You can also then restrict the access to the "hiddenfiles" folder using a .htaccess file inside of said folder.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.