Load data infile help

Discussion in 'MySQL' started by maxell6230, Feb 18, 2010.

  1. #1
    I have recently written a php script to load csv files into a database which was all working fine until I noticed that LOAD DATA is loading the file twice, even if a specify a single csv file is loads the data into the table twice. Any help would be appreciated as it's been driving me nuts for the last six hours.

    Thanks in advance.
     
    maxell6230, Feb 18, 2010 IP
  2. georgiivanov

    georgiivanov Member

    Messages:
    62
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    25
    #2
    You are calling "LOAD DATA" from your PHP script, right? Have in mind that LOAD DATA in MySQL loads the file EXACTLY one time. This means that you are calling it twice. Put some debug echo

    echo "Calling LOAD DATA...";
    mysql_query("LOAD DATA...

    and debug your script.
     
    georgiivanov, Feb 18, 2010 IP
  3. maxell6230

    maxell6230 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for reply. WHen I put the echo statement in I only get one instance of it, so I can't see/how or why it runs twice. I get no errors with mysql_query. It is a php script.. Very confusing this one.
     
    maxell6230, Feb 19, 2010 IP
  4. maxell6230

    maxell6230 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Fixed it, stupidity on my part, I was using mysql_query($query) to runthe query and then error checking with if(mysql_query($query)) hence it was putting it in twice. Thanks
     
    maxell6230, Feb 19, 2010 IP