djanim8 Posted August 2, 2007 Share Posted August 2, 2007 right now I have a CSV file that I'm having users upload and insert the data into a mySQL database.. the file (at this time, it will get bigger and bigger) has over 11,000 lines in it.. The page continually times out.. right now I have the timeout set: set_time_limit(3600); it always gives me a CGI error when it gets about 3/4 the way through it... no matter how long I set the the set_time_limit to.. CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers. does anyone have any suggestions on how to fix this? Quote Link to comment https://forums.phpfreaks.com/topic/63001-time-out-on-csv-file/ Share on other sites More sharing options...
djanim8 Posted August 2, 2007 Author Share Posted August 2, 2007 here is all the code if it helps: set_time_limit(3600); $handler = fopen($_FILES['fleMusicCSV']['tmp_name'],'r'); $addCount = 0; $totCount = 0; $existsCount = 0; if($_POST['chkDelete'] <> "") { $mySQL = "DELETE FROM songs"; $deleteResults = mysql_query($mySQL); $songID = 0; } else { $mySQL = "SELECT * FROM songs ORDER BY songID DESC"; $getResults = mysql_query($mySQL); $songRow = mysql_fetch_array($getResults); $songID = $songRow['songID']; } while ($row = fgetcsv($handler,1024,",","")) { $artist = $row[0]; $title = $row[1]; $genre1 = $row[2]; $genre2 = $row[3]; $disc = $row[4]; $track = $row[5]; $firstDance = $row[6]; $brideFather = $row[7]; $groomMother = $row[8]; $couplesDance = $row[9]; $boquet = $row[10]; $garter = $row[11]; $songID++; $mySQL = "INSERT INTO songs (songID,artist,title,genre1,genre2,disc,"; $mySQL .= "track,firstDance,brideFather,groomMother,couplesDance,boquet,garter"; $mySQL .= ") VALUES ("; $mySQL .= "'".$songID."','".$artist."','".$title."','".$genre1."','".$genre2."','".$disc."','"; $mySQL .= $track."','".$firstDance."','".$brideFather."','".$groomMother."','".$couplesDance."','".$boquet."','".$garter."')"; $uploadResult = mysql_query($mySQL); if($uploadResult) { $addCount++; } else { echo "There is something wrong on row ".$totCount." and I can't insert this record into the database!<br>"; } echo ""; $totCount++; } fclose($handler); Quote Link to comment https://forums.phpfreaks.com/topic/63001-time-out-on-csv-file/#findComment-313728 Share on other sites More sharing options...
seikan Posted August 2, 2007 Share Posted August 2, 2007 I also facing this problem before. I solved it by changing MySQL query. Change the query fom: INSERT INTO songs (songID,artist,title,genre1,genre2,disc,track,firstDance,brideFather,groomMother,couplesDance,boquet,garter) VALUE (..., ..., .....) INSERT INTO songs (songID,artist,title,genre1,genre2,disc,track,firstDance,brideFather,groomMother,couplesDance,boquet,garter) VALUE (..., ..., .....) .. to: INSERT INTO songs (songID,artist,title,genre1,genre2,disc,track,firstDance,brideFather,groomMother,couplesDance,boquet,garter) VALUE (..., ..., .....), (..., ..., .....), (..., ..., .....),(..., ..., .....) Hope this can help. Quote Link to comment https://forums.phpfreaks.com/topic/63001-time-out-on-csv-file/#findComment-313732 Share on other sites More sharing options...
djanim8 Posted August 2, 2007 Author Share Posted August 2, 2007 I'm going to try this out.. I'll let ya know, hope it works! Quote Link to comment https://forums.phpfreaks.com/topic/63001-time-out-on-csv-file/#findComment-313950 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.