I'm following the first answer given here (Importing CSV data using PHP/MySQL) but I'm probably messing up some basic thing.
Here how my code looks now:
<?php
$accounts = mysql_connect('localhost','root','mypass')
or die (mysql_error());
mysql_select_db("dbname",$accounts);
$fileName='./myfile.csv';
$query = <<<eof
LOAD DATA INFILE '$myfile.csv'
INTO TABLE tbname
FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(ID,Entity,HOOK,Period,Status,Trade,etc)
eof;
$dbname->query($query);
?>
Im getting and error in my last line as it follows:
"Undefined variable: dbname in C:\xampp\htdocs\mycode\loadcsv.php on line 17"
which prob mean that I didn't properly load that &dbname is as a db? I did managed to retrieve data from the same db using the same connection.
Any help in what the line
$dbname->query($query);
does is welcomed!
tks in advance!