Guest User

Untitled

a guest
Apr 12th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. $mysqlDatabaseName ='postcodes';
  2. $mysqlUserName ='root';
  3. $mysqlPassword ='';
  4. $mysqlHostName ='localhost';
  5. $mysqlImportFilename ='http://localhost/import_tbl/postcode_withLatlang.sql';
  6.  
  7. $command='mysql -h' .$mysqlHostName .' -u' .$mysqlUserName .' -p' .$mysqlPassword .' ' .$mysqlDatabaseName .' < ' .$mysqlImportFilename;
  8.  
  9. //var_dump( file_exists('postcode_withLatlang.sql') );
  10.  
  11. $output = array();
  12.  
  13. exec($command, $output, $worked);
  14. print_r($output);
  15. echo $worked;
  16.  
  17. // test whether they are imported successfully or not
  18. switch ($worked) {
  19. case 0:
  20. echo 'Import file <b>' .$mysqlImportFilename .'</b> successfully imported to database <b>' .$mysqlDatabaseName .'</b>';
  21. break;
  22. case 1:
  23. echo 'There was an error during import. Please make sure the import file is saved in the same folder as this script and check your values:<br/><br/><table><tr><td>MySQL Database Name:</td><td><b>' .$mysqlDatabaseName .'</b></td></tr><tr><td>MySQL User Name:</td><td><b>' .$mysqlUserName .'</b></td></tr><tr><td>MySQL Password:</td><td><b>NOTSHOWN</b></td></tr><tr><td>MySQL Host Name:</td><td><b>' .$mysqlHostName .'</b></td></tr><tr><td>MySQL Import Filename:</td><td><b>' .$mysqlImportFilename .'</b></td></tr></table>';
  24. break;
  25. }
Add Comment
Please, Sign In to add comment