I’ve been stuck on this for four days now, so I’m here to seek some help. I’m very new to php and I’ve been trying to import an csv file into my database through code.
- on the LOAD DATA line, it says “unexpected T_STRING”
- Nothing ever uploads to SQL, there’s 100% no connections issues though.
This is my code, what am I doing wrong?:
[php] <?php
$servername = “localhost”;
$username = “user”;
$password = “password”;
$dbname = “mattsDB”;
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error); }
LOAD DATA LOCAL INFILE (‘hi.csv’)
INTO TABLE names
FIELDS TERMINATED BY ‘,’
ENCLOSED BY ‘"’
LINES TERMINATED BY ‘\n’
IGNORE 1 ROWS
(firstname);
?>
[/php]