Mark,
I was able to get this to work on my end with a test program.
Here is what I did:
1) Create a dummy mySQL database
DbImportCsv.sql
create database Test;
use Test;
create table TestTable
(
title varchar(64) NOT NULL,
author varchar(64) NOT NULL
);
Then create the database by:
c:\mysql\bin\mysql < DbImportCsv.sql
2) Create a comma seperated variable text file called DbImportCsv.txt.
DbImportCsv.txt
Gone with the wind, Shakespeare
The Bible, God
The Jungle, Upton Sinclair
THIS FILE MUST BE STORED IN THE DATABASE DIRECTORY WHERE TEST IS LOCATED
3) Created php code to load the text file into the database
<?php
$dbHost = "localhost";
$dbUser = "";
$dbPassword = "";
$dbName = "Test";
$dbConn = mysql_connect($dbHost, $dbUser, $dbPassword);
if ($dbConn == false)
{
echo "Could not connect to database";
exit(1);
}
if (mysql_select_db($dbName, $dbConn) == false)
{
echo "Could not select database";
exit(2);
}
$sql = "LOAD DATA INFILE 'DbImportCsv.txt' INTO TABLE TestTable FIELDS TERMINATED BY ','";
echo $sql;
if (mysql_query($sql, $dbConn) == false)
{
echo "Could not execute query";
exit(2);
}
mysql_close($dbConn);
exit(0);
?>