Jump to content

control for insert CSV file in mysql


prince198

Recommended Posts

hi evrybody

 

i insert csv file in mysql with php. it's work fine and i can also show how many lines was insert

but i want to controle if the row that i insert is number or not. if is not show the line in csv  that contain

errors

 

this is script

<?php
$current_row = 1;
           $str=file_get_contents("file.csv");
           $rows=$this->CSV2Array($str);
	      for($i=0;$i<count($rows);$i++)
                              {
   

                                        $sql="INSERT IGNORE INTO atm_2008 (line1,line2)
                               values('".$rows[$i][0]."','".$rows[$i][1]."')";
                                $this->Inserer= $this->db->prepare($sql);
	                        $this->Inserer->execute();
                            }

?>

for function CSV2Array is function that i found in php manual ti open and extract csv file

so a s you see . in for programm insert csv file but i can't foud solution to controle for example row [$i][0] if is number or nor and show where is errors in csv

i use exit but is true he found errors and stop insert but show no errors and not wehre errors

 

i hope that u unterstand probleme

thanks for helping

Link to comment
https://forums.phpfreaks.com/topic/122937-control-for-insert-csv-file-in-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.