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

  • Home
  • SEARCH
  • 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 6607321
In Process

The Archive Base Latest Questions

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

See the code below, there are two databases connections. First it get the data

  • 0

See the code below, there are two databases connections.

First it get the data from first connection and then insert into second database connection but it will not insert – I can an error saying Unknown column 'fullname' in 'field list'

When I tried SQL query manually in phpMyAdmin and it work fine…

$db_new = mysql_connect('localhost', 'root', 'password');
if (!mysql_select_db("menu_new", $db_new)) {
    die("Cant connect menu_new DATABASE");
}

$db_old = mysql_connect('localhost', 'root', 'password');
if (!mysql_select_db("old_menu", $db_old)) {
    die("Cant connect old_menu DATABASE");
}

$SQL_old = "SELECT * FROM old_table";
$q = mysql_query($SQL_old, $db_old);

while ($row = mysql_fetch_assoc($q)) {
    $name = $row['name']; 

    $SQL = "INSERT INTO tbl_name (fullname) values ('$name')";

     //Problem Here - It wont insert into second database
     mysql_query($SQL, $db_new) or die(mysql_error($db_new));
}
  • 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-25T19:29:28+00:00Added an answer on May 25, 2026 at 7:29 pm

    Thanks @Konerak for suggestion and that does work!

    To Insert/Select data from Database connection, you will have to include database name before the table name.

    For Example

    From:

    mysql_query("INSERT into tbl_name (fullname) values ('1')", $db_new) or die(mysql_error($db_new));
    

    To:

    mysql_query("INSERT into menu_new.tbl_name (fullname) values ('1')", $db_new) or die(mysql_error($db_new));
    

    That is really odd though.

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

Sidebar

Related Questions

See code below, for some reason it only works when I put a breakpoint
How come unserialize isn't restoring my array? See code below.. // prints a:1:{s:8:txn_type;s:32:recurring_payment_profile_cancel;} echo
I have a table defined (see code snippet below). How can I add a
EDIT: See my working code in the answers below. In brief: I have a
Update: Solved, with code I got it working, see my answer below for the
I am using ActiveRecord in Rails 3 to pull data from two different tables
The code below is more or less taken from the example MPMoviePlayerController sample code.
What is the difference in the two blocks of code below? I expected them
See code: var file1 = 50.xsl; var file2 = 30.doc; getFileExtension(file1); //returns xsl getFileExtension(file2);
I often see code like: Iterator i = list.iterator(); while(i.hasNext()) { ... } but

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.