Note that there are some explanatory texts on larger screens.

plurals
  1. POLoad data infile gives me an access denied permissions error. How else can I import a text file into my table in my database?
    text
    copied!<p>I want to import a text file that contains data separated by , . I read on several sources that most people use, "LOAD DATA INFILE". So, I figured it would work for me too. </p> <p>I get this permissions error however when I do so. I ran this command and here is what I got: </p> <pre><code>LOAD DATA INFILE '/public_html/nyccrash.txt' INTO TABLE nyccrash; </code></pre> <p>But it gives me this error: </p> <pre><code>ERROR 1045(28000): Access denied for user 'username'@'%' (using password: YES) </code></pre> <p>I read on some other threads that all I had to do was include the full file path and I did but it still didn't work. </p> <p>Is there another way to import a text file into my table in my database? Using SQL or PHP. </p> <p>EDIT: </p> <p>I found this command I can use: </p> <pre><code>&lt;?php $row = 1; $handle = fopen("nyccrash.txt", "r"); echo("&lt;table&gt;"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { echo("&lt;tr&gt;\r\n"); foreach ($data as $index=&gt;$val) { echo("\t&lt;td&gt;$val&lt;/td&gt;\r\n"); } echo("&lt;/tr&gt;\r\n"); } echo("&lt;/table&gt;"); fclose($handle); </code></pre> <p>?></p> <p>That allows me to read the data and create a table and print it. I can also use the INSERT INTO table sql command after using the above to collect the data but I'm not sure how to insert the values into the table. That is, loop through the values for insertion. My data in the txt file doesn't not contain the attributes or headers of what's contained. So... I'm a little confused on how to sort the data into the right columns. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload