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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:26:16+00:00 2026-06-14T09:26:16+00:00

I am coding some PHP working with two MySQL databases. What I am working

  • 0

I am coding some PHP working with two MySQL databases. What I am working toward is different information to be sourced from the two databases which will then populate some form fields like the drop-down menu. The form will then be posted to create a printable document yada yada…

What Works

The connection to the first database works fine, the field is populated and there are no errors.

What Doesn’t Work

When I introduce the second Database I get no errors but the form wont populate. I make this change…

From One Database:

$sql = mysql_query"SELECT * FROM car WHERE color='blue' ORDER BY sqm ASC";

To Two Databases:

$sql = mysql_query("SELECT * FROM car WHERE color='blue' ORDER BY sqm ASC", $conn);

The Connection

Source: http://rosstanner.co.uk/2012/01/php-tutorial-connect-multiple-databases-php-mysql/

How do you connect to multiple MySQL databases on a single webpage?

<?php  
// connect to the database server  
$conn = mysql_connect("localhost", "cars", "password");  

// select the database to connect to  
mysql_select_db("manufacturer", $conn);  

// connect to the second database server  
$conn2 = mysql_connect("localhost", "cars", "password");  

// select the database to connect to  
mysql_select_db("intranet", $conn2);  
?> 

The Execution

It appears that $sql = mysql_query(“SELECT * FROM car WHERE color=’blue’ ORDER BY sqm ASC”, $conn); Is my problem

<form name="form" method="post" action="review.php">
<table><td>
    <select>
    <option value="">--Select--</option>
<?php $sql = mysql_query("SELECT * FROM car WHERE color='blue' ORDER BY sqm ASC", $conn);  
      $rs_result = mysql_query ($sql); 

// get the entry from the result
   while ($row = mysql_fetch_assoc($rs_result)) {

// Print out the contents of each row into a table 
   echo "<option value=\"".$row['carname']."\">".$row['carname']."</option>";
    }
?>
    </select>
</td></table>
</form>

Thanks In advance for any help 🙂

  • 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-14T09:26:18+00:00Added an answer on June 14, 2026 at 9:26 am

    you’ve got 2 mysql query commands going…

    <?php
    $sql       = mysql_query("SELECT * FROM car WHERE color='blue' ORDER BY sqm ASC", $conn);  
    $rs_result = mysql_query ($sql); // <-- $sql here is the result of the first query (ie. not a sql command)
    

    should be

    <form name="form" method="post" action="review.php">
    <table><td>
        <select>
        <option value="">--Select--</option>
    <?php
        $sql = "SELECT * FROM car WHERE color='blue' ORDER BY sqm ASC";
        $rs_result = mysql_query( $sql, $conn );
    
        // get the entry from the result
        while ($row = mysql_fetch_assoc($rs_result)) {
            // Print out the contents of each row into a table 
            echo "<option value=\"".$row['carname']."\">".$row['carname']."</option>";
        }
    ?>
        </select>
    </td></table>
    </form>
    

    good luck!

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

Sidebar

Related Questions

I'm working on a project that involved getting information from two different servers. What
I am working on some form coding in PHP, and I have everything working
I am trying to get some information from our database and then use it
I m working on module in which i have to make pdf from php
This is some code from a php file im working with. I need to
A long shot but here's hoping someone has some experience coding PHP hooks for
Coming from PHP with some Java Struts 2.0 experience any tips/tricks on learning GWT?
I'm currently working on some coding for a hotel booking widget and am using
I've been working on web apps for a while now, using php and then
I'm working on a page where I've listed some entries from a database. Although,

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.