How to import an sql file into mySQL using PHP

Discussion in 'PHP' started by adzeds, Jul 29, 2010.

  1. #1
    I have a PHP file on my server and I want to import that to my mysql database using a PHP script.

    Anyone help with this, am doing my nut in as I can't get it to work.
     
    adzeds, Jul 29, 2010 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    <?php

    passthru("nohup mysql -u USERNAME -pPASSWORD DBNAME < dump.sql");

    ?>

    i hope it helps

    Regards

    Alex
     
    kmap, Jul 29, 2010 IP
  3. adzeds

    adzeds Well-Known Member

    Messages:
    1,209
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    100
    #3
    I have tried that, it appears to run the script but the data in the database does not update...
     
    adzeds, Jul 29, 2010 IP