Hello
I am trying to (!) write some code that will allow me to import the data from an Access created csv file into mySQL database. I cannot change the formatting of the Access .csv file as this is what I have been given to work with.
I have noted that the format of this Access .csv is different from the .csv file I have created from my mySQL database, and I think that this is causing some of the problems I am having when I try to import the data.
I need some code to specifiy to mySQL what to expect in the way of delimiters.
I am thinking implode / exlpode / str_replace from what I have seen on these forums, but I am at a loss where to start
Any suggestions will be greatly received - thanks
The code I have so far is as follows, but running this code i am getting the error message bool(false)
require_once ('../mysql_connect.php');//connect to the database
$filename = "Client.csv";
$fp = fopen($filename,"r") or die('could not open file!');
while (!feof($fp)){
while ($data = fgetcsv($fp,5000));
var_dump($data); // to echo out the info
// to see if it is being recognised
$ClientId = $data[0];
$ConcesRef = $data[1];
$CoName = $data[2];
$Addr1 = $data[3];
$Addr2 = $data[4];
$Addr3 = $data[5];
$Town = $data[6];
$County = $data[7];
$Postcode = $data[8];
$Phone = $data[9];
$Fax = $data[10];
$sql = "INSERT INTO tblClient (ClientId, ConcesRef, CoName, Addr1, Addr2, Addr3, Town, County, Postcode, Phone, Fax)
VALUES ('$ClientId', '$ConcesRef', '$CoName', '$Addr1', '$Addr2', '$Addr3', '$Town', '$County', '$Postcode', '$Phone', '$Fax')";
$result = mysql_query($sql)
or die(mysql_error());
}