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 8808291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:35:10+00:00 2026-06-14T02:35:10+00:00

The script below is used for updating schema of 100 databases. I am making

  • 0

The script below is used for updating schema of 100 databases.

I am making one call to mysql_connect, does mysql_select_db cause another connection to be made or am I ok? (I run this script to update the schema of 100 or so database)

$conn = mysql_connect("localhost", "root", "PASSWORD");
$show_db_query = mysql_query('SHOW databases');
$databases = array();
while ($row = mysql_fetch_assoc($show_db_query)) 
{ 
    if (!in_array($row['Database'], $exclude_dbs))
    {
        $databases[] = $row['Database'];
    }
}

foreach($databases as $database)
{
    mysql_select_db($database, $conn);
    echo "Running queries on $database\n***********************************\n";
    foreach($sql_queries as $query)
    {
        if (!empty($query))
        {
            echo "$query;";
            if (!mysql_query($query))
            {
                echo "\n\nERROR: ".mysql_error()."\n\n";
            }
        }
    }
    echo "\n\n";
}
  • 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-06-14T02:35:11+00:00Added an answer on June 14, 2026 at 2:35 am

    As long as mysql_select_db found a last connection or a connection identifer is supplied with the calling statment, it does not create a new connection.

    Since you are passing a connection identifer so it does not create a new connection to mysql. you are safe to go in this case of multiple connection but be aware that mysql extension is no longer maintained, you could try mysqli or PDO.

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

Sidebar

Related Questions

I wrote a jQuery script (below) and I used the (document).ready(function($)) function does it
I'm using this script below for loading a hidden div, inside another: $(document).ready(function(){ $(function()
The script below is used to hide a paragraph until all text fields inside
The script provided below res.php is designed to scale images that are then used
I have used script below and the output is X value : 123 Y
Whenever we redirect from one page to another page, Query string can be used.
I used the codes(html+php script) below to upload image file submit.html <html> <body> <form
I have successfully used below script to get predefined text highlighted in the textarea.
Suppose I have a Java program Test.class , if I used the below script
The script below works fine if 3 and 3.2 are not links but i

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.