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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:46:27+00:00 2026-06-14T12:46:27+00:00

I want to retrieve two different fields residing in different data bases. My db

  • 0

I want to retrieve two different fields residing in different data bases. My db connection settings are this:

 define ('DB_HOST',     'ipaddress1');
 define ('DB_USER',     'username1');
 define ('DB_PASSWORD', 'password1');
 define ('DB_DATABASE', 'ecbooks');
 $db_wink = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, TRUE) or  die("Connection Error: " . mysql_error());
 mysql_select_db(DB_DATABASE) or die("Error connecting to Winkstore DB. " . mysql_error());

 // DB configuration parameters : magonwink
 define ('DB_REMOTE_HOST',     'ipaddress2');
 define ('DB_REMOTE_USER',     'username2');
 define ('DB_REMOTE_PASSWORD', 'password2');
 define ('DB_REMOTE_DATABASE', 'magsonwink');

 $db_magson = mysql_connect(DB_REMOTE_HOST, DB_REMOTE_USER,  DB_REMOTE_PASSWORD, TRUE) or die("Connection Error: " . mysql_error());
 mysql_select_db(DB_REMOTE_DATABASE, $db_magson) or die("Error connecting to magson wink DB. " . mysql_error());

 define ('CMS_DB_HOST',     'ipaddress3');
 define ('CMS_DB_USER',     'username3');
 define ('CMS_DB_PASSWORD', 'password3');
 define ('CMS_DB_DATABASE', 'mawinkcms');

 $db_rp = mysql_connect(CMS_DB_HOST, CMS_DB_USER, CMS_DB_PASSWORD, true) or die("Connection Error: " . mysql_error());
 mysql_select_db(CMS_DB_DATABASE, $db_rp) or die("Error connecting to DB. " . mysql_error());

but when I used this query

 SELECT ecbooks.user.user_name AS field1, mawinkcms.purchase.USER_NAME AS field2 FROM ecbooks.user,mawinkcms.purchase
 $result     = mysql_query($query, $db_wink) or die("Couldn't execute query: " . mysql_error());
 while($row = mysql_fetch_assoc($result)){
 $users[] = $row;
 }

I got an error could not execute the query. Thanks in advance.

  • 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-14T12:46:28+00:00Added an answer on June 14, 2026 at 12:46 pm

    Firstly, when asking for help with an error, it’s a good idea to include the error itself.

    Secondly, your query doesn’t appear to have a join condition, so you will get back the cartesian product if you do get it to go – that’s probably not what you want.

    Thirdly, when running a query, it runs against the database you connected to, regardless of whether you’ve connected to any others. So, in your example, you’re running a query against $db_wink; the other two connections don’t affect this at all.

    For the query to work, the user who connected to $db_wink needs to have permissions on the databases ecbooks and mawinkcms, and mawinkcms must be running on the same server as ecbooks.

    I’m guessing that either the permissions are not set up, or you’re running them on different databases.

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

Sidebar

Related Questions

I have two XML sources to retrieve data from. I want to use them
Hi guys i have my array below and i want to retrieve two rows:as
I have a HTML table as follows. I want retrieve row values from this
I have a database where I store two different kinds of data. One table
I have two different servers, and I need to send post data from one
I'm kinda stuck with this task. I have a macro that retrieve two ranges
I want to call a method where two parametres are objects (one retrieve Person,
I want retrieve the width and height of browser in pixel(px) using ruby code.
What I want retrieve task whch due element is overdue. What the XML is
I want to retrieve the last 3 registered users in cakephp using the field

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.