Results 1 to 2 of 2

Thread: using LOAD DATA INFILE

  1. #1
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default using LOAD DATA INFILE

    So I have a project coming up that I will most likely need to use this, so I was testing to make sure I understand how to do it beforehand. Here is the code I am using
    PHP Code:
    if (isset($_POST['load']))
    {
    require(
    'connect2.php');
    $temp $_FILES['myfile']['tmp_name'];
    $sqlstatement="LOAD DATA INFILE '$temp' INTO TABLE inventory FIELDS TERMINATED BY ',' ";
    mysql_query($sqlstatement) or die(mysql_error());
    echo 
    "It worked";

    HTML Code:
    <form method="post" action="load.php" enctype="multipart/form-data">
    <input name="myfile" type="file" />
    <input name="load" type="submit" value="submit" /></form>
    The reason I want to use this I think is cause the file that the client will be using is a exported csv file from Quickbooks and I want it to be easy for them to upload and have it update their inventory on the site and this will be a long inventory list.

    Now the issue I am having is that when I try the upload it seems to do that fine but gives me this
    HTML Code:
    Access denied for user 'C304016_rsmnprod'@'%' (using password: YES)
    I am using the same exact connect.php that the entire rest of the site uses to display all the data currently in the DB so I know that that is correct. I even called my hosting company to verify if they know if the server allows or not the LOAD DATA INFILE, they are checking at the moment. Now I have used INSERT on many pages without fail and I understand this is variation of that so why does it give me the error.

    The table exists in the DB and has columns labeled accordingly, also it doesn't matter what type of file I try it gives the same message.

  2. #2
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    So why is it right after I post something I find the answer. Found a note the if the script is on a hosting server you need to include LOCAL in the query. So like this
    PHP Code:
    $sqlstatement="LOAD DATA LOCAL INFILE '$temp' INTO TABLE inventory FIELDS TERMINATED BY ',' "

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •