MySQL Database Connection (two databases at the same time)

I have never had to open more than one MySQL database from within the same website before, but I do now.  The website I have is designed where all the content comes from within the main database.  I am building an Inventory system that I want within it's own database, in the event I would ever need to move the application to another server or something, I don't want this data residing in the main database.
Currently, I open the database connection from within a file called "common.php" that resides in a directory called "lib" that can be accessed from the root directory.  Below is the proposed code that would be placed within the "common.php" file:
// Define Database Variables
$dbserver = "127.0.0.1";
$dbuser  = array('clevelan_user1', 'clevelan_user2');
$dbpass  = array('P@ssw0rd', 'P@ssw0rd2');
$dbname  = array('clevelan_database1', 'clevelan_database2');
// Start Session
session_start();
// Connect to Databases
connectdb($dbserver, $dbuser[0], $dbpass[0], $dbname[0]);
connectdb2($dbserver, $dbuser[1], $dbpass[1], $dbname[1]);
// Database 1 Connection
function connectdb($dbserver, $dbuser, $dbpass, $dbname) {
// connects to db
  global $connection;
  $connection = @mysql_connect($dbserver, $dbuser, $dbpass) or die ("could not connect to server");
  $db = @mysql_select_db($dbname, $connection) or die ("could not select databsase");
  return $connection;
// Database 2 Connection
function connectdb2($dbserver, $dbuser, $dbpass, $dbname) {
// connects to db
  global $connection2;
  $connection2 = @mysql_connect($dbserver, $dbuser, $dbpass) or die ("could not connect to server");
  $db2 = @mysql_select_db($dbname, $connection2) or die ("could not select databsase");
  return $connection2;
//End of Code Within the "common.php"
From within any page of the website, I want to access both connections by placing an include at the top of each page:
include_once("lib/common.php");
Currently, when I run the code above, any page within the website (the home page) provides error messages with regards to database connectivity (the pages are looking for there content from within the second database.  It's as if the second database is the only database seen by the website.
I need help figuring out how I can have two MySQL databases open at the same time (the second database will only be open for short periods of time and then closed).  But the main database is always open.

Create one project using one copy of the exact tables.
create 2 different sessions.xml files each pointing to the same project. Set the login information in the sessions.xml files.
That should work fine.
Peter

Similar Messages

  • Bluetooth - Connecting two devices at the same time on a Run (Bluetooth Mot headset

    I would like to connect two Bluetooth devised at the same time on my runs.  (Bluetooth Motorola headset (S10-HD) and Polars heart monitor (H7) at the same time)  is that possible? 

    fitnessdr wrote:
    Thank you for the information.  So if I were to return the new bluetooth keyboard, should I purchase the "Palm 3169WWZ Wireless Keyboard", or is there another model I should be looking for?  (From what I can tell, I believe this one will use IR.)
    THANKS!
    Correct, that's the one I use. 
    Be sure to download the newest driver (1.13) for the keyboard from the Palm Support pages for the keyboard:
    http://kb.palm.com/wps/portal/kb/na/keyboards/palmuniversalwirelesskeyboard/unlocked/downloads/page_...
    Do not install the driver that comes with the device on the disk - 1.13 is designed for the TX and fixes a bug that existed in the original driver.
    WyreNut
    I am a Volunteer here, not employed by HP.
    You too can become an HP Expert! Details HERE!
    If my post has helped you, click the Kudos Thumbs up!
    If it solved your issue, Click the "Accept as Solution" button so others can benefit from the question you asked!

  • Trouble connecting two computers at the same time

    I have a Macbook Pro with a 802.11g airport card. A friend has a 802.11n airport card. When I am online the 802.11n computer can't get online using the airport extreme n station. I suspect that this is because of the diference between n and g, but I cant find a way to either switch her airport card to g, or switch the station to g...any ideas?
    It is also password wpa/wpa2 personal
    thank you!

    Unfortunately that hasn't worked. The g card is working fine, but the n cant go online when the g is online. They both are recognized and accepted by the airport station, but it will only let the g online if they are both logged on at the same time.

  • Can we start more than one user created database at the same time

    Hi.,
    Can we start/work more than one user created database at the same time ??
    --Shyam                                                                                                                                                                                       

    Hi Shyam,
    I really dont understand what you have asked?
    If your question is can we start more than one database at the same time then the answer to that is yes but provided to have enough resources on your server to support running of two or more different databases on the same machine.
    Ex Senior DBA

  • How can i use offline & online database in the same time?

    how can i use offline & online database in the same time?
    my database in another server when the connection true it connect
    but if not does not work
    i wanna make offline database if the server not connected it connect offline then the server is on it alter all data from the offline to the server.

    User, please tell us your Jdev version!
    There is no such functionality build into the framework. The offline data base is only for designing the db, not to have a backup db.
    If you can't connect to the db the application will not work.
    Timo

  • How doi unistall itunes from an iphone? By accident we connected two phones to the same itunes account. So now whenever one downloads something, both phones receive the download.

    How do I uninstall an itunes account from an iphone? By accident we connected two phones to the same itunes account and now whenever we download both  phones receive the download.

    Settings > iTunes & App Store > Automatic Downloads > switch off what you don't want here

  • How can I connect two PS3 to the same Linksys WRT54G correctly

    Hi,
    i'm trying to connect two PS3 to the same routeur without having conflicts. Everytime i try to update my game softwares it tells me error 80710723 or now 8002AD23. I gave the two PS3 different IP adresses, i opened all the ports that Playstation suggested me to open (http://playstation.custhelp.com/app/answers/detail/a_id/241) and gave them different DNS adresses but still they cannot download any software content without bugging the console. I also use a PC, Tablet and Phone with my wireless connection.
    thank you
    -François

    Well in this case the error code (80710723 ) is generated when the internet connection is slow. So you can try the following step:
    # Open up the browser and on the address bar type 192.168.1.1 that will open up the Router setup page.
    # Lower the MTU (Maximum Transmission Unit) from 1500 to 1400 or less (usually found on your router's main/ basic setup page)
    # Make the Channel Width to 20 MHz only and Channel to 6, 9, 11..
    #Adjust the following advanced wireless settings:
    ~~ Lower the beacon interval from 100 to 75
    ~~ Lower the fragmentation threshold from 2346 to 2306
    ~~ Lower the RTS threshold from 2347 to 2304

  • Cannot connect two computers to the same game server HELP!

    I have a Linksys WRT54G Router.  I have two computers and I want to be able to use them on the same gaming server.  Unfortunately, the game only have one port, so I can only port forward one of my computers.  How can I configure my router to have two external IP addresses to the server so it won't kick one of my computers out.  Thanks!

    Hi,
    I am in a gaming community and many members have a Linksys at home (but I don't know which kind exactly). Many of us try to connect two computers to the same server (many have a family). It seems it is a common problem that no one can connect two computers to the same game server.
    I have a BEFSR41 V3 Firmware version 1.04.8
    I use fixed IP address and no connectivity problem on Internet.
    I have win XP SP2 on both computer.
    I am using a DSL modem
    I can connect the two computers to two different game servers at same time, but not the same server. Default port for this game is the same for all servers I use. I tried with both port forwarding enabled (in that case one PCs can connect the other not) or not (in the second case, whenever the second PC connects, the first one lose his connection to the server, no mater the order I try to connect my PCs).
    Now the weird thing is that one member in my community just decided to throw away his Linksys router and he bought another brand (which I won't name to remains politically correct). Now, without changing anything in his PCs or his connection type, he can now play with two PC on the same server.
    I am seriously thinking doing the same move. Since more and more game are now using Internet (and servers that controls piracy, $$) and family want to play together, not being able to connect two PCs on the same game server makes Linksys in bad situation from marketing point of view.
    For example, in my gaming communtity, we now all know that Linksys can't handle two PC on same server, but other brand can...
    Thank you in advance for your help.

  • Connecting two WRT54GS to the same (wired) router (non-linksys)

    Due to some security issue I have to connect two WRT54GS to the same wired router.
    Do I connect the first WRT54GS to one port of the router and the second one to another port?
    And is the connection on the WRT the ethernetport or the internetport?
    And can I reach both the configuration screens or do I have to change the
    adress of one of them to e.g. 192.168.1.2 ?
    Regards,
    hENK.  

    I will suggest you to connect the LAN port of wired router to LAN ports of both WRT54GS  ........  Th connectino to WRT54GS is Ethernet Port ......
    Regarding the Ip address of WRT54GS ..... change the Ip address of first wireless router from 192.168.1.1 to 192.168.1.2 ........make the DHCP service disabled ....
    For the other router the Ip address would be 192.168.1.3 ...... DHCP service again disabled .........
    For accessing the set up page of both router use the new Local Ip address.........on the explorer address bar ......

  • [Bug] Writing to the same trace in Citadel from two Sources at the same time

    Howdy
    I am experiencing an issue and am looking to get some NI support:
    I have two distributed applications that can write to a Citadel database at the same time.
    And I am investigating the possibility of what would occur if both of them were writing to the same variable at the same time, with possibly the same timestamp data.
    I did this in the attached VI by using the same timestamps with a constant for the data (either #1 or #2).
    This generates an error, as expected, stating you cannot have two references open at the same time.
    The data file, dumped from Citadel, contains 1000pts with all data from only one of the arrays (in this case #2) and everything looks fine:
    However, what appears to be happening randomly tho, is that the same portion of code can also returns no error.
    When the data is dumped from Citadel this file contains 2001pts - 1000pts from each array and one separator (or break) point:
    You cannot write an older timestamp to Citadel without it throwing an error, but from further testing it seems you can write the same timestamp repeatably. So I am guessing what is happening above is race condition that is somehow allowing two references to be opened to Citadel which should throw an error but it does not and this is somehow allowing both sets of data to be written by both loops??
    The data, IMO, is now corrupted.
    Is being able to write to the same timestamp a desirable feature?
    Or is this a known issue or a bug?
    What about acquiring two references - bug?
    Is there a workaround to protect the data from multiple distributed-application writes?
    Cheers
    -JG
    Attached VI was coded and tested using LabVIEW 2009 SP1, DSC 9.0.1, MAX 4.6.2f1
    Certified LabVIEW Architect * LabVIEW Champion
    Attachments:
    dual_databaseWrite.vi ‏21 KB

    Ben S wrote:
    The race condition of opening the refererence in two places at once should still apply to two different VIs running at the sametime.
    Will a CAR be lodged for this?
    Ben S wrote:
    If you open up the code and save it as a .vit, you don't get any missing VIs. Only when you change the extension without the aid of LabVIEW.
    No VI should have missing members by simply renaming its extension outside of LabVIEW???
    I think there is an issue with the VI.
    Can you replicate the following and verify what I am seeing?
    Attached is a Project with Main VI (contains a call to the Open Trace.vi polymorphic only), a Class and a Build Spec
    If you Build the spec with the Main VI outside of the Class it works
    If you place the VI in the Class, save then Build, the Spec fails with the error:
    Visit the Request Support page at ni.com/ask to learn more about resolving this problem. Use the following information as a reference:
    Error 1003 occurred at AB_Application.lvclasspen_Top_Level_VIs.vi -> AB_Build.lvclass:Build.vi -> AB_Application.lvclass:Build.vi -> AB_EXE.lvclass:Build.vi -> AB_Engine_Build.vi -> AB_Build_Invoke.vi -> AB_Build_Invoke.vi.ProxyCaller
    Possible reason(s):
    LabVIEW:  The VI is not executable. Most likely the VI is broken or one of its subVIs cannot be located. Select File>>Open to open the VI and then verify that you are able to run it.
    Visit the Request Support page at ni.com/ask to learn more about resolving this problem. Use the following information as a reference:
    Error 1003 occurred at AB_Application.lvclass:Open_Top_Level_VIs.vi -> AB_Build.lvclass:Build.vi -> AB_Application.lvclass:Build.vi -> AB_EXE.lvclass:Build.vi -> AB_Engine_Build.vi -> AB_Build_Invoke.vi -> AB_Build_Invoke.vi.ProxyCaller
    Possible reason(s):
    LabVIEW: The VI is not executable. Most likely the VI is broken or one of its subVIs cannot be located. Select File>>Open to open the VI and then verify that you are able to run it.
    Next place a disabled structure around the Polymorphic VI (as Class Member or not, it doesn't matter)
    Save the VI
    Close the VI
    Open the VI - the Open Trace.vi polymorphic is "missing"
    Cheers
    -JG
    Code in LV2009
    Certified LabVIEW Architect * LabVIEW Champion
    Attachments:
    DSC.zip ‏341 KB

  • Singletons running on two servers at the same time

    Hello,
              we faced one interesting situation with our application, running on clustered BEA Weblogic 9.2. We implemented some Singletons (ie. Singleton Service in a Weblogic cluster) and they are running fine. Most of the time.
              Common scenarios: cluster is started -> the singletons run on one server; the server is brought down -> the singletons are started on the second server.
              However, we had recently two situations where the Singletons started on both servers! Here they are:
              1) We use Database Migration Basis and we have a dedicated table for Weblogic to capture current state of the singletons. Due to the fact that database (Oracle RAC) was partially available one of the Managed Server could not get the lease and probably assumed that no singleton is running, therefore started the singletons locally.
              2) Network outage: we had several minutes where none of our servers could communicate between them (neither between SASU MS nor with the database). Consequence: each MS decided to start the singleton locally (after some time, which I assume is the waiting time). Once the network came back the servers could communicate again but the duplicate singletons are not deactivate, so they are running in parallel.
              Anyone experienced the same or similar issues? How to prevent the above? Is the Consensus Migration Basis a better choice? (I think yes for #1 but not for situation #2).
              Any helpful answer is appreciated.
              Thank you, best regards,
              Remus.

    In general its not a good idea.  Running PSConfig will try to establish a lock on the configuration database.  Doing that from two servers at the same time may cause the update to fail.
    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

  • Can I access two websites at the same time?

    Does Dreamweaver have the ability to open two websites at the same time?
    I basically have a CMS hosted on one server, that connects to my clients sites on other servers. I want to be able to open files on one server and edit them and also edit files on another server at the same time.
    If this isn't available in Dreamweaver, then I think it should be. I often need to copy code from one page in a site to another page in different site. To have the ability to have two windows open, each connected to a different website server would be invaluable to me. By having separate windows, each can have its own server connection. I don't know how easy that would be, but I'd love it!
    Cheers
    Glynn

    You can only connect to one site at a time.  And you need to edit files locally, save & then upload to the remote server.   AFAIK, no single FTP app is capable of connecting to more than one server at a time.  You might be able to do what you want with DW open and an additional 3rd party FTP client like Filezilla, each connecting to different servers.
    Nancy O.

  • I AM TRYING TO HOOK UP TWO MONITORS AT THE SAME TIME

    I AM TRYING TO HOOK UP TWO MONITORS AT THE SAME TIME. I have had no success in figuring out why I can get an image on my TV and an image on my monitor (at the same time), but no icons, no start menu and no keyboard access. M y computer freezes as well when I try to do 2 monitors.

    Hi,
    Your machine has:
    *Integrated video is not available if a graphics card is installed.
    Radeon HD 6370D, 6410D, 6530D or 6550D Graphics (model dependent based on processor)
    Supports PCI Express x16 graphics cards
    Two DVI-D ports (Both ports can be used at the same time)
    You can use TWO monitors with the right connections for two ports #3 above. You can get more information from the following instructions:
       http://www.dummies.com/how-to/content/how-to-set-up-multiple-monitors-with-windows-7.html
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • Can I shuffle two playlists at the same time?

    How can I shuffle two playlists at the same time?  Thank you.

    You can only connect to one site at a time.  And you need to edit files locally, save & then upload to the remote server.   AFAIK, no single FTP app is capable of connecting to more than one server at a time.  You might be able to do what you want with DW open and an additional 3rd party FTP client like Filezilla, each connecting to different servers.
    Nancy O.

  • Telnet two devices at the same time 1 C# program

    Hi, currently I have one 100% working program used to telnet my Arduino circuit.
    I use this C# class found somewhere around the web: Anyway, without this forum, I wouldn't be able to finish my program.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Net.Sockets;
    namespace USSR
    enum Verbs
    WILL = 251,
    WONT = 252,
    DO = 253,
    DONT = 254,
    IAC = 255
    enum Options
    SGA = 3
    class TelnetConnection
    TcpClient tcpSocket;
    int TimeOutMs = 100;
    public TelnetConnection(string Hostname, int Port)
    tcpSocket = new TcpClient(Hostname, Port);
    public string Login(string Username, string Password, int LoginTimeOutMs)
    int oldTimeOutMs = TimeOutMs;
    TimeOutMs = LoginTimeOutMs;
    string s = Read();
    if (!s.TrimEnd().EndsWith(":"))
    throw new Exception("Failed to connect : no login prompt");
    WriteLine(Username);
    s += Read();
    if (!s.TrimEnd().EndsWith(":"))
    throw new Exception("Failed to connect : no password prompt");
    WriteLine(Password);
    s += Read();
    TimeOutMs = oldTimeOutMs;
    return s;
    public void WriteLine(string cmd)
    Write(cmd + "\n");
    public void Write(string cmd)
    if (!tcpSocket.Connected) return;
    byte[] buf = System.Text.ASCIIEncoding.ASCII.GetBytes(cmd.Replace("\0xFF", "\0xFF\0xFF"));
    tcpSocket.GetStream().Write(buf, 0, buf.Length);
    public string Read()
    if (!tcpSocket.Connected) return null;
    StringBuilder sb = new StringBuilder();
    do
    ParseTelnet(sb);
    System.Threading.Thread.Sleep(TimeOutMs);
    } while (tcpSocket.Available > 0);
    return sb.ToString();
    public bool IsConnected
    get { return tcpSocket.Connected; }
    void ParseTelnet(StringBuilder sb)
    while (tcpSocket.Available > 0)
    int input = tcpSocket.GetStream().ReadByte();
    switch (input)
    case -1:
    break;
    case (int)Verbs.IAC:
    // interpret as command
    int inputverb = tcpSocket.GetStream().ReadByte();
    if (inputverb == -1) break;
    switch (inputverb)
    case (int)Verbs.IAC:
    //literal IAC = 255 escaped, so append char 255 to string
    sb.Append(inputverb);
    break;
    case (int)Verbs.DO:
    case (int)Verbs.DONT:
    case (int)Verbs.WILL:
    case (int)Verbs.WONT:
    // reply to all commands with "WONT", unless it is SGA (suppres go ahead)
    int inputoption = tcpSocket.GetStream().ReadByte();
    if (inputoption == -1) break;
    tcpSocket.GetStream().WriteByte((byte)Verbs.IAC);
    if (inputoption == (int)Options.SGA)
    tcpSocket.GetStream().WriteByte(inputverb == (int)Verbs.DO ? (byte)Verbs.WILL : (byte)Verbs.DO);
    else
    tcpSocket.GetStream().WriteByte(inputverb == (int)Verbs.DO ? (byte)Verbs.WONT : (byte)Verbs.DONT);
    tcpSocket.GetStream().WriteByte((byte)inputoption);
    break;
    default:
    break;
    break;
    default:
    sb.Append((char)input);
    break;
    My UI Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Net.Sockets;
    namespace USSR
    public partial class mainForm : Form
    TelnetConnection tc;
    public bool keyPressChecker = false;
    public bool connectedChecker = false;
    public mainForm()
    InitializeComponent();
    // webBrowser1.Navigate("http://admin:[email protected]");
    this.tc = null;
    this.connectedChecker = false;
    private void radioButton2_CheckedChanged(object sender, EventArgs e)
    try
    if (submarineRadioBtn.Checked)
    System.Diagnostics.Process.Start("dummySub.exe");
    catch (Exception ex)
    MessageBox.Show(ex.ToString());
    private void centerBtnCamera_Click(object sender, EventArgs e)
    private void forwardBtn_Click(object sender, EventArgs e)
    if (connectedChecker)
    this.tc.WriteLine("W");
    private void connectToolStripMenuItem1_Click(object sender, EventArgs e)
    try
    //create a new telnet connection
    tc = new TelnetConnection("192.168.0.102", 23);
    if (tc.IsConnected)
    connectedChecker = true;
    catch (Exception ex)
    MessageBox.Show(ex.ToString());
    private void controlKeyDownCheckBox_CheckedChanged(object sender, EventArgs e)
    if (controlKeyDownCheckBox.Checked == true)
    keyPressChecker = true;
    else
    keyPressChecker = false;
    private void controlKeyDownCheckBox_KeyDown(object sender, KeyEventArgs e)
    if (keyPressChecker == true)
    if (e.KeyCode == Keys.W)
    if (connectedChecker)
    tc.WriteLine("W");
    if (e.KeyCode == Keys.S)
    if (connectedChecker)
    tc.WriteLine("S");
    private void reverseBtn_Click(object sender, EventArgs e)
    if (connectedChecker)
    tc.WriteLine("S");
    private void disconnectToolStripMenuItem_Click(object sender, EventArgs e)
    try
    tc = null;
    connectedChecker = false;
    catch (Exception ex)
    MessageBox.Show(ex.ToString());
    private void controlKeyDownCheckBox_KeyUp(object sender, KeyEventArgs e)
    if (keyPressChecker == true)
    if (e.KeyCode == Keys.W)
    if (connectedChecker)
    tc.WriteLine("O"); //decrease to MID PT.
    if (e.KeyCode == Keys.S)
    if (connectedChecker)
    tc.WriteLine("P"); //decrease speed to MID PT.
    private void exitToolStripMenuItem_Click(object sender, EventArgs e)
    Application.Exit();
    Now, what I want to know is this: IS IT POSSIBLE FOR MY C# PROGRAM TO TELNET TWO DEVICES AT THE SAME TIME? 
    Thanks
    Glenn

    try this links :
    http://www.codeproject.com/Articles/19071/Quick-tool-A-minimalistic-Telnet-library
    http://stackoverflow.com/questions/25116077/send-and-receive-commands-via-telnet-in-c-sharp
    http://stackoverflow.com/questions/12283241/ssh-to-server-then-telnet-to-device

  • Write a progarm to test two parts at the same time

    Hi:
    I need to write a program in LabView that is capable of testing two parts at the same time.
    Explanation:
    I star the test on a unit, once all the electrical test is done move that unit to the pressure test without loosing the current test information and continue the test of the unit thewn generate a serial number only if it passes all the test. Then while the previous unit is going thru the pressure test star testing another unit for the elecrical test and so on.
    I am using LabView 2012

    From what you have described, I agree with what has been answered above. TestStand is specifically designed for. If you would like to provide more information about your application we could give you a more detailed response. For more information about TestStand follow this link
    www.ni.com/teststand
    Ryan
    Ryan
    Applications Engineer
    National Instruments

Maybe you are looking for

  • Irritating problem with adding columns

    I am adding columns to jtable. And then moving it to required postion. But whenever I edit those columns all the newly added columns and the first column reflects those changes. ie whatever I enter in the new columns, it appears in all newly added co

  • Creating new PDF's from the input of a form

    I posted a similar message to this one about 3 months ago. I had to work on other projects and also learn more about the process to make this happen. In a nutshell, here's what I'm trying to accomplish: User downloads form from our website and fills

  • I'm unable to initiate outbound calls since tha last iOS 7.1.2 update, anyone got the same issue

    After I updated my iPhone 5 to iOS 7.1.2, I was unable to dial any single number from my contacts in a couple of hours. I still got that issue when I load my phone up to 100%

  • Help with form function

    Hi All, I'm having problems gathering information from one form ('product') and placing it into another ('accepted') so that i can submit the information into an email using php. I need to retrieve the options chosen from the 'product' form and inser

  • WSF multiple scripts start? Newbie question

    So I have a script that is called within a VB app. When I let it run alone, there is no problem. However, when I start to click around in Windows, several instances of the script fire. I end up going to task manager to kill jobs. It's as though the s