2012-08-28 82 views
0

我有一個PHP的形式,其中一個用戶給我看,他們收到一個致命的錯誤:不一致的致命錯誤:最長30秒的執行時間超過

Maximum execution time of 30 seconds exceeded in C:\Program Files\Apache2.2\htdocs\eeallparts\registration.php on line 282. 

奇怪的是,他們又重新提交表單和表單工作,因爲它應該將數據插入到數據庫中,所以這不是一致的錯誤。我在表單上收到了很多意見(這些表單相當程度上是垃圾郵件),所以我知道表單通常可以工作,但這種隨機錯誤顯然困擾着我。

我去了線282,我唯一看到的是這樣的:

if(!$insertContact_query = mssql_query($sql)) {  

我看過一些與此相關的其他線程建議看set time limit的。如果查詢花費太長時間,查詢幾乎總是超時而不是週期性地超時?我讓用戶在表單中重新提交了相同的信息,並且第二次運行?

+0

你的網頁做了多少工作?它是添加數百行數據,還是僅僅是一對? – andrewsi

+0

可能存在底層SQL服務器本身存在的問題(性能問題,碎片等),或者您擁有任何PHP緩存(dis/en)能力。 – Breakthrough

+0

「如果查詢花費的時間太長,查詢幾乎不會」不,這可能是一個鎖定問題,這取決於衝突。它可能需要更長的時間在流量高峯期,... – Tchoupi

回答

1

時間限制不包括花費在查詢數據庫所花費的時間等任何外部數據源上的時間。

The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. This is not true on Windows where the measured time is real.

如果查詢返回大數據集,它可能僅在處理集合時超時。如果可能,請使用php配置文件指出瓶頸。

+2

「在測量時間是真實的Windows上,這不是真的。」,如果仔細觀察問題,您會看到海報正在運行Windows。 SQL查詢/引擎肯定會導致這種情況。 –

+0

你說得對。我一直在我的PHP開發中使用Linux,並沒有注意到這一點。 – NathanD

相關問題