close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Connect to 2 different databases on the same page

Thread began 1/27/2017 8:03 am by Accumike | Last modified 2/01/2017 12:59 pm by Accumike | 1963 views | 6 replies


Connect to 2 different databases on the same page

This is a bit complicated... I want to pull property information from another web site & database into my CRM system.

I can do this if I include two connections at the top of the page:

<?php require_once('../Connections/crm_realpress_wa.php'); ?>
<?php require_once('../Connections/realpress_property.php'); ?>

The first handles my crm data, the second my property data. No problem.

But I want to make the second db connection dynamic, so that the crm user can connect to different databases as required.

Using the old ADDT recordset extension, I have done this by making a db query at the top of the second connection and then passing the info into the actual connection parameters.

This is similar code for MySQLi:

<?php require_once('../Connections/crm_realpress_wa.php'); ?>
<?php require_once('../webassist/mysqli/rsobj.php'); ?>
<?php // Get Connections to Property Database in RealPress site
$rsDBConnections = new WA_MySQLi_RS("rsDBConnections",$crm_realpress_wa,0);
$rsDBConnections->setQuery("SELECT id_dbc, idlic_dbc, domain_url_dbc, connection_name_dbc, hostname_dbc, database_dbc, username_dbc, password_dbc, iddbc_lic FROM cu_db_connection_dbc LEFT JOIN cs_licensee_lic ON id_dbc=iddbc_lic WHERE idlic_dbc = ? AND iddbc_lic IS NOT NULL");
$rsDBConnections->bindParam("i", "".$_SESSION['wa_user_licence'] ."", "-1"); //colname

# FileName="WADYN_MYSQLI_CONN.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_realpress_dynamic_db = $rsDBConnections->getColumnVal("hostname_dbc");
$database_realpress_dynamic_db = $rsDBConnections->getColumnVal("database_dbc");
$username_realpress_dynamic_db = $rsDBConnections->getColumnVal("username_dbc");
$password_realpress_dynamic_db = $rsDBConnections->getColumnVal("password_dbc");
$realpress_dynamic_db = new mysqli($hostname_realpress_dynamic_db, $username_realpress_dynamic_db, $password_realpress_dynamic_db, $password_realpress_dynamic_db);

I then replace the connection 'realpress_property' with 'realpress_dynamic_db' and it should connect.

Howver, I have tried this using the code above, but it won't work - all I get is the actual SQL SELECT query showing on the page and nothing else.

Am I doing something wrong, or is this no longer possible with MySQLi?

All suggestions welcome, thanks.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...