COMMAND LINE STYLE!

heh. Was wondering if there was a way to do this either via php or mysql to take a .sql file already on the server and import it

    Well, if you've got phpMyAdmin on the server, you could just use that to upload the .sql file and import it into the mysql database. If you want to use the command line, then there's a program included with the mysql daemon called mysqlimport. You can find some info about it at http://dev.mysql.com/doc/mysql/en/mysqlimport.html , or (assuming a *nix os), by using the man page. Or you could write a php script that reads the file line by line and does a mysql_query() on each line, like follows:

    <?php
    $file = fopen("file.txt", "r");
    
    ####################
    # connect to mysql database 
    ####################
    
    foreach($file as $line) {
        mysql_query($line);
    }
    
    ##################
    # close mysql connection   
    ##################
    ?>
    
      Write a Reply...