This is part of an import routine I have been writing.
PHP Code:
$row 1;
$handle fopen("http://www.supplierurl.com/feed/feed6.csv""r");
$new_products="";
$existing_products="";
$to_remove_products="";
$instock 0;
$outstock 0;
$totalproducts 0;
$newproducts 0;
$deletedproducts 0;
mysql_query("update products set products_status=99 ");
while ((
$data fgetcsv($handle1000",")) !== false) {
    
$num count($data);
 
//
    
$row++;
    if(
$row>2){
    for (
$c 0$c $num$c++) {
        if (
$c == 0$pname_orig str_replace('"''' $data[$c]);
        if (
$c == 2$pid str_replace('"''' $data[$c]);
        if (
$c == 4$cat str_replace('"''' $data[$c]);
        if (
$c == 5$subcat str_replace('"''' $data[$c]);
        if (
$c == 7$prod_description_orig str_replace('"''' $data[$c]);
        if (
$c == 11$price str_replace('"''' $data[$c]);
        if (
$c == 8)$img str_replace('"''' $data[$c]);
        if (
$c == 9)$img2 str_replace('"''' $data[$c]);// Get 2nd image file name
        
if ($c == 14) {
  
$stock str_replace('"''' $data[$c]);
  if(
$stock=='True'){ $q=100;$instock++;} else {$q=0$outstock++;}
  }
        if (
$c == 15)$weight str_replace('"''' $data[$c]);
    } 
Most of the time this works, but sometimes it does not pick the feed file up properly, and sees the file as empty. This clears all my products and ends up placing lots of empty rows in the database.

Can someone help me with the code required to check that the file is present, and check it is not empty. If there is a problem with the file, I would rather it did not run the the import, and just send an email saying import file error.

Any help would be appreciated.

Thanks
Laurie