Think I'm missing something here. I can print/echo the $sql variable and paste it into phpMyadmin and it works just fine, but for some reason it will not work correctly here. Anybody see anything off?
Thank you
<?php ///Write Text File To Local Database //declare variables $i='1'; $handle= fopen('inventory.txt','r'); $sql=''; $find='"'; $replace=''; $first=''; $second=''; ///read file while(!feof($handle)) { $gets = fgets($handle,4096); list($first,$second)=explode(',',$gets); //create sql $sql.="INSERT INTO facts_inventory (`part_number`,`facts_qty_on_hand`) VALUES ('".trim(str_replace($find,$replace,$first))."','".trim(str_replace($find,$replace,$second))."') ON DUPLICATE KEY UPDATE `facts_qty_on_hand` = '".trim(str_replace($find,$replace,$second))."';"; $i++; } if(mysql_query($sql)) { ///it Worked echo 'Updated '.$i.' fields.'; } else { //Query Failed echo "<br>Failed at executing sql query. "; } ?>