TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-21-2008, 03:22 PM   #1 (permalink)
The Acquainted
 
Dave's Avatar
 
Join Date: Apr 2008
Posts: 110
Thanks: 97
Dave is on a distinguished road
Default Issues on php.ini

Hello to everyone --

I ran a PHP program the other day and got the "30" second server timeout error.

I looked about the internet for a solution, and found an advisory post where the author recommended changing the php.ini settings to a timeout to 120 seconds and upping the script memory from 8K to 256K.

I did this and the program ran as intended.

So, my question is, are there any repercussions for changing these settings? Or, is it just a willy-nilly, harmless thing like picking a shirt color?

Thanks,
Dave
Dave is offline  
Reply With Quote
Old 06-21-2008, 04:10 PM   #2 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

In most circumstances, in particular websites, you shouldn't want a script to be running for 30 seconds or longer. If a page took that long to load, chances are your visitors would have gone elsewhere way before 30 seconds elapsed but it's a good point to cut off further execution to prevent things running for a long time (for any number of reasons). The official reasoning (from the PHP Manual) would be that it "helps prevent poorly written scripts from tying up the server".

Rather than changing the php.ini settings, which will affect every PHP file, you can change the values just for the currently running script (unless running under 'safe mode') by using ini_set() (for max_execution_time and memory_limit).
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
Dave (06-22-2008)
Old 06-21-2008, 05:44 PM   #3 (permalink)
Jim
The Addict
 
Jim's Avatar
 
Join Date: Nov 2007
Location: the Netherlands
Posts: 281
Thanks: 2
Jim is on a distinguished road
Default

You can also use the set_time_limit() function.
__________________
Nunchaku! Who doesn't like martial arts? =)
Send a message via MSN to Jim Send a message via Skype™ to Jim
Jim is offline  
Reply With Quote
The Following User Says Thank You to Jim For This Useful Post:
Dave (06-22-2008)
Old 06-22-2008, 08:40 PM   #4 (permalink)
The Acquainted
 
Dave's Avatar
 
Join Date: Apr 2008
Posts: 110
Thanks: 97
Dave is on a distinguished road
Asterix Thanks for the information

Salathe and Jim --

Thanks for your information. I'll switch to using the "extended server time" option within programs and change back the php.ini settings to their defaults.

See you next time,
Dave
Dave is offline  
Reply With Quote
Old 06-22-2008, 09:15 PM   #5 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

You dont want every script on your server to be able to run more than 30 seconds. In most cases it means something is wrong, in others it means a resource is taking too long. One way or another, it could easily get really taxing on your server, especially if someone plots an attack using it. Use ini_set() to set the particular scripts that need to run that long.
__________________

Village Idiot is offline  
Reply With Quote
The Following User Says Thank You to Village Idiot For This Useful Post:
Dave (06-23-2008)
Old 06-23-2008, 02:56 AM   #6 (permalink)
The Acquainted
 
Dave's Avatar
 
Join Date: Apr 2008
Posts: 110
Thanks: 97
Dave is on a distinguished road
Default

Thanks!

Actually, this is a -- don't know how to explain this -- sort of a desktop application (written in PHP) that I'm working on...My "localhost" server was giving me the timeout error...So, this is not a web app just yet.

Dave
Dave is offline  
Reply With Quote
Old 06-24-2008, 06:25 AM   #7 (permalink)
The Wanderer
 
unitechy's Avatar
 
Join Date: Mar 2008
Location: navi mumbai
Posts: 10
Thanks: 4
unitechy is on a distinguished road
Default

Quote:
Originally Posted by Dave View Post
Thanks!

Actually, this is a -- don't know how to explain this -- sort of a desktop application (written in PHP) that I'm working on...My "localhost" server was giving me the timeout error...So, this is not a web app just yet.

Dave
even if you are using it as "desktop app" you must have installed server on your desktop to do so!
so indirectly its an web app
__________________
How to crash your pc??
Send a message via AIM to unitechy Send a message via MSN to unitechy Send a message via Yahoo to unitechy Send a message via Skype™ to unitechy
unitechy is offline  
Reply With Quote
The Following User Says Thank You to unitechy For This Useful Post:
Dave (06-24-2008)
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:13 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design