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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.