开发者

PHP fgetcsv encounters Fatal error: Maximum execution time exceeded on Firefox

First of all I guess that "fatal error: maximum execution time exceeded" in PHP is a server side error and shouldn't depend on browser 开发者_JAVA百科version, right? But seems it does!?!

I have this code to read csv data coming from a text area in a form.

$handle = tmpfile();
fwrite($handle, $csvclip);
fseek($handle, 0);
while (!feof($handle)) {
   $r = fgetcsv($handle, 1000, $delimiter, '"'); <---- Here it gives Fatal Error
   print $r[0];
}

And data is this, nothing special, 4 columns and 3 rows.

a   b   1   2
c   d   3   4
e   f   5   6

Code works on all browsers (IE, Chrome, e.t.c), I can see my parsed data except Firefox!!!!! I tested on different PCs but same. All browsers are ok but Firefox gives "Fatal error: Maximum execution time exceeded" for line having "fgetcsv"

I'm using PHP Version 5.2.10 and 2 different firefox versions 3.5.16 and 3.6.6

Anyone have seen this problem before?

Edit: Code is tested on two different linux servers CentOS 5.3 and 5.5, using two different PC having all browsers.

Edit 2: SOLVED

Ok I found the problem. $delimiter value comes from a having 3 values "," ";" and "\t" which browsers display "\t" as spaces in and I didn't pay attention to it.

Seems firefox is doing something to \t so PHP doesn't understand that it's tab. But other browsers sends \t as expected.

If I hardcode "\t" like fgetcsv($handle, 1000, "\t", '"') works fine also with firefox.

First time Firefox caused me that much trouble and not IE :)


Add the following to the top of your script:

set_time_limit(0);

This should disable the time limit for your script to run.


Not sure if it's the problem here, but take a look at Tom's comments from 24-Oct-2006 10:27 on the feof() page


Ok I found the problem. $delimiter value comes from a having 3 values "," ";" and "\t" which browsers display "\t" as spaces in and I didn't pay attention to it.

Seems firefox is doing something to \t so PHP doesn't understand that it's tab. But other browsers sends \t as expected.

If I hardcode "\t" like fgetcsv($handle, 1000, "\t", '"') works fine also with firefox.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜