Importing a sql file into a remote mysql db with php
<p>New to php and mysql, 
I am trying to insert a exported sql file into a remote DB.
I am try this code from <a href="https://help.1and1.com/hosting-c37630/scripts-and-programming-languages-c85099/php-c37728/importing-and-exporting-mysql-databases-using-php-a595887.html" rel="nofollow">1and1</a> but it is not working. </p>

<pre><code>$create_install_db_server = 'testdb.example.com';
$create_install_db_username = 'test123';
$create_install_db_password = 'test789';
$create_install_db_name = 'test';
$sqlfile = '/home/path/to/localsql.sql';

$command='mysql -h' . $create_install_db_server .' -u' . $create_install_db_username .' -p' . $create_install_db_password .' ' . $create_install_db_name .' &lt; ' . $sqlfile;
exec($command,$output=array(),$worked);
switch($worked){
    case 0:
        echo 'Import file &lt;b&gt;' .$mysqlImportFilename .'&lt;/b&gt; successfully imported to database &lt;b&gt;' .$mysqlDatabaseName .'&lt;/b&gt;';
        break;
    case 1:
        echo 'There was an error during import.';
        break;
}
</code></pre>