For loop problems...
Posted: Fri Feb 19, 2010 2:59 pm
...i am trying to import information from a .txt file into a mysql database, while at the same time when an if function is met, checking another .txt file and importing information from that file as well into the database...the line of when taken out, does not allow the two files to be compared, but at least the information from the first .txt file is all inputed into the database, but when...
...thank you for your help...darwin
Code: Select all
if($n == $item_number_1."p"){$poplar = $p;}Code: Select all
$fh = fopen($myFile, 'r');
$data = fread($fh, filesize($myFile));
$fh2 = fopen($myFile2, 'r');
$theData = fread($fh2, filesize($myFile2));
$wordChunks = strtolower($wordChunks);
$wordChunks = str_replace('"', '', "$wordChunks");
$wordChunks = explode("\r\n", $data);
$ccount = count($wordChunks);
$Chunks = strtolower($Chunks);
$Chunks = str_replace('"', '', "$Chunks");
$Chunks = explode("\r\n", $data);
$Ccount = count($Chunks);
for($i = 0; $i < $Ccount; $i++){
list($page,$item_number_1,$size,$info,$pricing,$pine,$poplar) = split('[,]', $Chunks[$i]);
if($poplar == 'y'){
for($s = 0; $s < $ccount; $s++){
list($n, $p) = split('[,]', $wordChunks[$s]);
if($n == $item_number_1."p"){$poplar = $p;}
}
}
mysql_query("INSERT INTO database (page,item_number_1,size,info,pricing,pine,poplar) VALUES('$page','$item_number_1',
'$size','$info','$pricing','$pine','$poplar')") or die('Error, query failed: '.mysql_error());
}
fclose($fh);
fclose($fh2);