Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6991621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:31:38+00:00 2026-05-27T19:31:38+00:00

In my site there have an installation part.In that the database is imported(the datbase

  • 0

In my site there have an installation part.In that the database is imported(the datbase backup file is in the root folder).So i want to list the tables name after the database import is done.That means if there have 10 tables , if table1 is imported then list table1 is imported ,if table2 is imported then list table2 is imported.

How can i do this?.

This is my ajax code;

function run_install()
{
//alert("process.php");
$.ajax({  
type: "POST",  
url: "process.php",
data: {method: 'database'},
success: function(msg){
//alert(msg);
}  
});
}

This is the functions in process.php page:

if($method == "database") {
    $base_url=$_SESSION['base_url'];
    $db_name=$_SESSION['db_name'];
    $uname=$_SESSION['uname'];
    $db_pwd=$_SESSION['pwd'];
    $db_host=$_SESSION['db_host'];
    clear_db($db_host,$uname,$db_pwd,$db_name);
    $conct=mysql_connect($db_host,$uname,$db_pwd);
    mysql_select_db($db_name,$conct);
    if(mysql_install_db($db_name, "launchrock.sql", $errmsg)) 
    {
    }
    else{
    echo 0;
    }
}

function mysql_install_db($dbname, $dbsqlfile, &$errmsg)
{
       $result = true;

       if(!mysql_select_db($dbname))
       {
          $result = mysql_query("CREATE DATABASE $dbname");
         if(!$result)
         {
            $errmsg = "could not create [$dbname] db in mysql";
            return false;
         }
         $result = mysql_select_db($dbname);


       if(!$result)
       {
          $errmsg = "could not select [$dbname] database in mysql";
          return false;
       }
      }
      else{
       $result = mysql_import_file($dbsqlfile, $errmsg);
        //$result = "dfgdfG";
       return $result;
       }
    } 

function mysql_import_file($filename, &$errmsg)
{
   /* Read the file */
       $lines = file($filename);

       if(!$lines)
       {
          $errmsg = "cannot open file $filename";
          return false;
       }

       $scriptfile = false;

   /* Get rid of the comments and form one jumbo line */
       foreach($lines as $line)
       {
          $line = trim($line);

          if(!@ereg('^--', $line))
          {
             $scriptfile.=" ".$line;
          }
       }

   if(!$scriptfile)
   {
      $errmsg = "no text found in $filename";
      return false;
      // $status==0;
   }

   /* Split the jumbo line into smaller lines */

   $queries = explode(';', $scriptfile);

   /* Run each line as a query */

   foreach($queries as $query)
   {
      $query = trim($query);
      if($query == "") { continue; }
      if(!mysql_query($query.';'))
      {
         $errmsg = "query ".$query." failed";
         return false;
        // $status==0;
      }
      else
      {
        $status=1;
      }
   }
   if($status==1)
   {
    return true;
   }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:31:39+00:00Added an answer on May 27, 2026 at 7:31 pm

    You can get a list of tables in a schema by using the SHOW TABLES sql statement.

    Are you aware that you can automatically run a bunch of SQL statements by using the mysql command-line client? Assuming your backup is an sql dump of the schema and data you could just run

    mysql -u {username} -p {password} {schema_name} < /path/to/backup/file
    

    Depending on your server/PHP set up you may be able to run this using the shell_exec() function. Note that this may mean your username and password are visible to other users on the same server via ps but you can get round this by using an options file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site where there will be a list of offers that the
I have a web site and there are some videos on it. I want
I have a wordpress site for ex, www.test.com There is a js file (forms.js)in
I have installed wordpress in root directory. There is a file say test.html in
I want to have a local Gitorious installation that cannot be accessed outside of
In my site there have some mailing options.Here iam sending an html mails. So
There have been multiple discussions on this topic in the site but I am
I have domain site.com and there is subdomain sub.site.com Once you open sub.site.com you
I have made a site where at the bottom of the page there is
i have multilingual asp.net site. there is a masterpage and default.aspx. I put two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.