Jump to content

For loop is not working


emexinc

Recommended Posts

...i am trying to import a .txt file into a mysql database and at the same time if a condition is met, then have some information changed with information from a second .txt file...

 

...here is my coding thus far...

 

$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);

$Chunks = strtolower($Chunks);
$Chunks = str_replace('"', '', "$Chunks");
$Chunks = explode("\r\n", $data);

for($i = 0; $i < count($Chunks); $i++){
list($page,$item_number_1,$size,$info,$pricing,$pine,$poplar) = split('[,]', $Chunks[$i]);

if($poplar == 'y'){
for($s = 0; $s < count($wordChunks); $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);

 

 

...thanks for the help...darwin

Link to comment
https://forums.phpfreaks.com/topic/192652-for-loop-is-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.