Reputation: 67
$tsvhandle = fopen($tsvfile, 'r');
while (($data = fgetcsv($tsvhandle, 1000, ";")) !== FALSE) {
$result = mysql_query("SELECT `post_id` FROM `charvest_postmeta` WHERE `meta_key` = '_sku' AND `meta_value` = '".$data[2]."'") or die($result."<br/><br/>".mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['post_id']. "</br>";
}
}
I receive " PHP Notice: Undefined offset: 2", but I don't understand what's the problem. Please help to me to fix that.
Thank you!
Upvotes: 0
Views: 1765
Reputation: 14314
$data
just don't have 3rd column (indexed 2) on some iteration.
You can check that within a loop: if (!isset($data[2])) { ...
Upvotes: 1