Genixdeae
04-14-2005, 10:22 AM
I have a script that uploads a csv file to a server then opens it to grab the data then insert it into the database. But the script keeps timing out. What im having the code do might not even work even if it didnt time out but it seems logical. any help appriciated.
BTW here's the code: $handle = fopen($_FILES["teacher_info"]["name"], "r");
while(($data = fgetcsv($handle, 1024, ",")) !== FALSE) {
$num = count($data);
$insert_teachers = "INSERT INTO `combo` (`firstname`, `lastname`, `fd_password`";
for($i=1;$i<=$num_per;$i++) {
$insert_teachers .= ", `period$i`";
}
$insert_teachers .= ") VALUES (";
for($d=0;$d<=$num;$i++) {
if($data[$d] == "") {
$tdata = "NULL";
}else{
$tdata = $data[$d];
}
$insert_teachers .= "'". $tdata ."',";
}//This is the line is times out on. It is the end of the for() statement
$insert_teachers .= ")";
}
fclose($handle);
echo $insert_teachers;
BTW here's the code: $handle = fopen($_FILES["teacher_info"]["name"], "r");
while(($data = fgetcsv($handle, 1024, ",")) !== FALSE) {
$num = count($data);
$insert_teachers = "INSERT INTO `combo` (`firstname`, `lastname`, `fd_password`";
for($i=1;$i<=$num_per;$i++) {
$insert_teachers .= ", `period$i`";
}
$insert_teachers .= ") VALUES (";
for($d=0;$d<=$num;$i++) {
if($data[$d] == "") {
$tdata = "NULL";
}else{
$tdata = $data[$d];
}
$insert_teachers .= "'". $tdata ."',";
}//This is the line is times out on. It is the end of the for() statement
$insert_teachers .= ")";
}
fclose($handle);
echo $insert_teachers;