SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Hiding from the world
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need help with Load data infile command

    Hi, Iam trying to insert data from a .txt file into my sql database but iam not very good at writing code. could someone please tell me where my code is wrong in the query, iam thinking its probably just a , or " in the that needs adding or taking away but i don't know. your help will be grately appreciated.

    Code:
    <?php
    //(1) open the database connection and use the *****
    //database
    $connection = mysql_connect("server","DB","password");
    mysql_select_db("DB",$connection);
    mysql_query("LOAD DATA INFILE 'beach.txt' INTO TABLE gbg_grade
    FIELDS TERMINATED BY ',' ENCLOSED BY '"'
    LINES TERMINATED BY '\n'");
    
    echo mysql_error();
    //(2) close the database connection
    mysql_close($connection);
    ?>

  2. #2
    SitePoint Guru asterix's Avatar
    Join Date
    Jun 2003
    Posts
    847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Please post the error message that you get.
    Try posting this problem in the PHP or the mySQL forums.

  3. #3
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Hiding from the world
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, i get a parse error on line 13 at the moment. should i post a new thread or get this one moved into the php mysql bit?. Thanks

  4. #4
    SitePoint Guru asterix's Avatar
    Join Date
    Jun 2003
    Posts
    847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code you posted does not have 13 lines, so it is difficult to help.

    Could you be more specific?

    Although my guess is that the file you are trying to load can't be found by mysql, you should try using a fully qaulified path like "c:\folder1\folder2\beach.txt" and then remember to give suffficient read access to the account under which mysql is running.


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
  •