Thanks for the fast response.
I have modified the code to fit in to my website.
I have set up 2 pages under a test area. The 2 pages I have set up are called 1.php and 2.php.
2.php contains a form that basically has a file input field and a submit button. On the click of the submit button the form is posted to 1.php. here is the code in the 1.php file:
Code: Select all
<?php
include 'dbc.php';
$data_file = $_POST['ascpbs'];
$table_name = "ascpbs_test";
$delimiter = ",";
$enclosure = "\"";
$eol = '\n';
$query = "
LOAD DATA INFILE '$data_file'
INTO TABLE $table_name
FIELDS TERMINATED BY '$delimiter' ENCLOSED BY '$enclosure'
LINES TERMINATED BY '$eol'
";
mysql_query($query) or die(mysql_error());
header("Location: 2.php?msg=Imported!");
exit();
?>
I have included my dbc.php file which contains all of the database information as shown below. I have used this method because I have alot of files that look to the same database for information and if I need to change the password or anything it makes it alot easier.
dbc.php file:
Code: Select all
<?php
$dbname = 'database_name';
$link = mysql_connect("host","User_name","password") or die("Couldn't make connection.");
$db = mysql_select_db($dbname, $link) or die("Couldn't select database");
?>
Now when I try the import code the error I get is an access denied error.
Now can anyone explain why this might be as the dbc.php file works fine with everything else.