Page 1 of 1

my script stops before finish the work

Posted: Thu Oct 23, 2008 5:21 am
by fabby
Hi.
I have a script that parse a csv and insert the dates into the database. In the csv are about 1000 rows, but when arrived between 100 and 200 it stop's.
I puted in the script, at the beginning, @set_time_limit(2000);
and in while instruction, i putted

ob_flush();
flush();

to see what rows insert.

In the same directory with the script i created php.ini and i puted


max_execution_time = 6000

Bat with all that, it staps. (now for example it stops at 363 row)

Re: my script stops before finish the work

Posted: Thu Oct 23, 2008 5:33 am
by onion2k
Inserting data into a database is very slow. If you insert 100s of rows it'll gradually go slower and slower because PHP can send the inserts to the database quicker than the database can actually do them. The best solution is to use MySQL's "LOAD DATE INFILE" syntax, but if that's not an option (if you need to manipulate the incoming data for example) then you could use the multi row insert syntax* to insert lots of rows all at a time. You'll have to be careful not to exceed MySQL's maximum packet size though.

* eg "INSERT INTO `table` (col1, col2, col3) VALUES ('val1','val2','val3'), ('val1','val2','val3'), ('val1','val2','val3'), ('val1','val2','val3');"

Re: my script stops before finish the work

Posted: Thu Oct 23, 2008 6:12 am
by fabby
not that is the problem
i want to know why the script stops, without any error!?

on localhost it works ok, but on the server up, not!

Re: my script stops before finish the work

Posted: Thu Oct 23, 2008 6:26 am
by onion2k
fabby wrote:not that is the problem
How do you know?

Re: my script stops before finish the work

Posted: Thu Oct 23, 2008 6:31 am
by fabby
so, the script, extract some data, and in a fild is a link with a picture. i have to copy the picture to the server, and this makes to work hard the script.
if i comment when have to copy the pictures, all the data is inserted.

and when it inserts about 200 rows, it stops, but the clint mozilla says that is's done, the page is loaded...but it isn't! :(

Re: my script stops before finish the work

Posted: Thu Oct 23, 2008 7:51 am
by staar2
You gonna need something else for this amount of data, as i understand you are inserting 200 pictures to database ?