Hi
I am uploading a csv file in the datbase. and i want to show an error message if the columns are more than 5.
I am counting the rows in the below script but it always prints row 1. I have spent lot of time to figure out and google it. all the examples in google looks similar to mine.
Can anyone find any issue with the below script and correct me pls
Thanks in advance
$row=1;
$error = 'No'; //////////initialise the error flag
while (($data = fgetcsv($handle, 1000, ",",'"')) !== FALSE) {
if( count($data) > 5 ){
//print_r($data);
$error = 'Yes' ; ///////////set the error flag to yes and break the loop . validation failed
$errorMess = 'There are more than 5 columns in row # '.$row ;
break ;
}
///////////////insert the data into stagging table if the column ==5///////////////////
//print_r($data);
$sqlLoad = "INSERT INTO ratecodes_stagging ( package_name,package_table,plan_name,plan_code,package_hierachy )
VALUES ('".addslashes($data[0])."','".addslashes($data[1])."','".addslashes($data[2])."','".addslashes($data[3])."',
'".addslashes($data[4])."')";
$resultSqlLoad = es_query($sqlLoad);
$row++;
//echo $i."<br>";
}//END while fgetcsv