LOAD DATA INFILE problem
Posted: Wed Sep 24, 2003 1:45 pm
I have an update script (included below) to replace the contents of a table with the contents of a text file to record the changes in an alumni database. The TRUNCATE command works perfectly. I always populate the db table with one dummy record before a test. TRUNCATE empties the db table. But the immediately following LOAD DATA INFILE command does nothing.
There appear to be no syntax errors since it always prints the test message. Any clue as to what I'm doing wrong here?
Thanks,
Paul Cardin
<?
// MySQL Settings
$MySqlHostname = "localhost";
$MySqlUsername = "class_admin";
$MySqlPassword = "*****";
$MySqlDatabase = "class_alumni";
/* make connection to database */
/* If no connection made, display error Message */
$dblink=MYSQL_CONNECT($MySqlHostname, $MySqlUsername, $MySqlPassword) OR DIE("Unable to connect to database");
/* Select the database name to be used or else print error message if unsuccessful*/
@mysql_select_db("$MySqlDatabase") or die( "Unable to select database");
mysql_query("TRUNCATE TABLE members");
mysql_query("LOAD DATA INFILE '/home/username/public_html/uploads/classupdate.csv' REPLACE INTO TABLE class_alumni.members FIELDS TERMINATED BY ',' LINES TERMINATED by '\n'");
echo ("End of Program Test.");
?>
There appear to be no syntax errors since it always prints the test message. Any clue as to what I'm doing wrong here?
Thanks,
Paul Cardin
<?
// MySQL Settings
$MySqlHostname = "localhost";
$MySqlUsername = "class_admin";
$MySqlPassword = "*****";
$MySqlDatabase = "class_alumni";
/* make connection to database */
/* If no connection made, display error Message */
$dblink=MYSQL_CONNECT($MySqlHostname, $MySqlUsername, $MySqlPassword) OR DIE("Unable to connect to database");
/* Select the database name to be used or else print error message if unsuccessful*/
@mysql_select_db("$MySqlDatabase") or die( "Unable to select database");
mysql_query("TRUNCATE TABLE members");
mysql_query("LOAD DATA INFILE '/home/username/public_html/uploads/classupdate.csv' REPLACE INTO TABLE class_alumni.members FIELDS TERMINATED BY ',' LINES TERMINATED by '\n'");
echo ("End of Program Test.");
?>