fgets() drops lines
Posted: Wed Feb 08, 2006 4:33 pm
Can anybody see anything in this code that would cause fgets() to drop specific lines?
I know that the lines end with a newline, and it's always the same lines that get dropped. And yes, I purposefully drop the very first line.
Code: Select all
$fp = fopen( $filename , "r" );
if ($fp) {
fgets( $fp, 4096 );
while ( !feof( $fp ) ) {
$line = fgets( $fp, 4096 );
$buf = explode( "\t", $line );
$query = "INSERT INTO $table VALUES (
'',
'',
'$buf[0]',
'$buf[1]',
'$buf[2]',
'$buf[3]',
'$buf[4]',
'$buf[5]',
'$buf[6]',
'$buf[7]',
'$buf[8]',
'$buf[9]',
'$buf[10]',
'$buf[11]',
'$buf[12]',
'$buf[13]',
'$buf[14]',
'$buf[15]',
'$buf[16]',
'$buf[17]',
'$buf[18]',
'$buf[19]',
'$buf[20]',
'$buf[21]',
'$buf[22]',
'$buf[23]',
'$buf[24]',
'$buf[25]',
'$buf[26]',
'$buf[27]' )";
$result = mysql_query($query);
}
fclose($fp);
}