freecrm
New Member
- Messages
- 629
- Reaction score
- 0
- Points
- 0
I've done quite a bit of reading on this but the subject is fraught with pitfalls.
I need to import data from a local csv file and have created the following code (adds to existing data).
<?php
require_once('Connections/freecrm.php');
mysql_select_db($database_freecrm, $freecrm)
or die("Could not open database");
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$varfilepath=$_POST['filepath'];
$sql =
"
LOAD DATA LOCAL INFILE '$varfilepath'
INTO TABLE TEST
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES
";
$result = mysql_query($sql)
or die ("Could not import data.");
}
?>
In the body, I have a form with 1 field (the file path), 1 hidden field to fulfil the "if" criteria and a submit button.
But I'm getting the response "Could not import data." which means I'm getting the connection but for some reason, it aint working!
Have I got a simple Syntax problem here or am I missing the point?
The page is currently at www.freecrm.x10hosting.com/test.php
Edit:
Does anyone have any idea what I'm on about?
I need to import data from a local csv file and have created the following code (adds to existing data).
<?php
require_once('Connections/freecrm.php');
mysql_select_db($database_freecrm, $freecrm)
or die("Could not open database");
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$varfilepath=$_POST['filepath'];
$sql =
"
LOAD DATA LOCAL INFILE '$varfilepath'
INTO TABLE TEST
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES
";
$result = mysql_query($sql)
or die ("Could not import data.");
}
?>
In the body, I have a form with 1 field (the file path), 1 hidden field to fulfil the "if" criteria and a submit button.
But I'm getting the response "Could not import data." which means I'm getting the connection but for some reason, it aint working!
Have I got a simple Syntax problem here or am I missing the point?
The page is currently at www.freecrm.x10hosting.com/test.php
Edit:
Does anyone have any idea what I'm on about?
Last edited: