my script stops before finish the work

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fabby
Forum Commoner
Posts: 62
Joined: Tue Feb 15, 2005 1:06 am
Location: Romania
Contact:

my script stops before finish the work

Post 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)
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: my script stops before finish the work

Post 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');"
fabby
Forum Commoner
Posts: 62
Joined: Tue Feb 15, 2005 1:06 am
Location: Romania
Contact:

Re: my script stops before finish the work

Post 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!
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: my script stops before finish the work

Post by onion2k »

fabby wrote:not that is the problem
How do you know?
fabby
Forum Commoner
Posts: 62
Joined: Tue Feb 15, 2005 1:06 am
Location: Romania
Contact:

Re: my script stops before finish the work

Post 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! :(
staar2
Forum Commoner
Posts: 83
Joined: Fri Apr 06, 2007 2:57 am

Re: my script stops before finish the work

Post by staar2 »

You gonna need something else for this amount of data, as i understand you are inserting 200 pictures to database ?
Post Reply