PHP return error when using fgetcsv -
possible duplicate:
mysql_fetch_array() expects parameter 1 resource, boolean given in select
hi i'm trying process csv fgetcsv i'm going infinite loop of errors
warning: fopen("tile","user"...) in testcsv.php on line 5
warning: fgetcsv() expects parameter 1 resource, boolean given in /home/ratena/public_html/proc_files/testcsv.php on line 6
<?php $uploadcsv = "/home/ratena/public_html/temp/files/batchloadpm15.csv"; $filecsv = file_get_contents($uploadcsv); //$batchid = $_post['batchid']; $handle = fopen("$filecsv", "r"); while (($data = fgetcsv($handle, 100000, ",")) !== false) { print_r($data); } ?>
this part having problem
/* un-necessary */ $filecsv = file_get_contents($uploadcsv); /* expecting file in */ $handle = fopen("$filecsv", "r");
try replace 3 lines
$handle = fopen($uploadcsv, 'r');
to skip first row
$column_headers = array(); $row_count = 0; while (($data = fgetcsv($handle, 100000, ",")) !== false) { if ($row_count==0) { $column_headers = $data; } else { print_r($data); } ++$row_count; }
Comments
Post a Comment