I am trying to use the script below to import data from a text file exported from access 97, but the script is not working. I am getting the message: "Invalid DELETE query". Could someone please help. Thank you.
<?php
# MySQL database User ID, Password and DB name
$sql_id = "root";
$sql_pwd = "password";
$sql_db = "inventorydb";
# Connect to the database
mysql_connect('',$sql_id,$sql_pwd);
# Delete the current content of the table
$result = mysql_db_query($db,"DELETE FROM checkout_db" or die ("Invalid DELETE query"
# Optimize the current table (recover empty space)
$result = mysql_db_query($db,"OPTIMIZE TABLE checkout_db" or die ("Invalid OPTIMIZE query"
# Load local comma separated, fields enclosed by quotes text database - File has to be in the same directory of this file
$result = mysql_db_query($db,"LOAD DATA LOCAL INFILE 'export_file_name.txt' INTO TABLE checkout_db FIELDS TERMINATED BY ',' ENCLOSED BY '\"'" or die ("Invalid DATA LOAD query"
# Get how many records are present in the table now
$result = mysql_db_query($db,"SELECT * from checkout_db" or die ("Invalid SELECT query"
$rows_count = mysql_num_rows($result);
echo "Records: $rows_count"; mysql_free_result($result);
?>
<?php
# MySQL database User ID, Password and DB name
$sql_id = "root";
$sql_pwd = "password";
$sql_db = "inventorydb";
# Connect to the database
mysql_connect('',$sql_id,$sql_pwd);
# Delete the current content of the table
$result = mysql_db_query($db,"DELETE FROM checkout_db" or die ("Invalid DELETE query"
# Optimize the current table (recover empty space)
$result = mysql_db_query($db,"OPTIMIZE TABLE checkout_db" or die ("Invalid OPTIMIZE query"
# Load local comma separated, fields enclosed by quotes text database - File has to be in the same directory of this file
$result = mysql_db_query($db,"LOAD DATA LOCAL INFILE 'export_file_name.txt' INTO TABLE checkout_db FIELDS TERMINATED BY ',' ENCLOSED BY '\"'" or die ("Invalid DATA LOAD query"
# Get how many records are present in the table now
$result = mysql_db_query($db,"SELECT * from checkout_db" or die ("Invalid SELECT query"
$rows_count = mysql_num_rows($result);
echo "Records: $rows_count"; mysql_free_result($result);
?>