The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
multiple database connection
#1
first of all thanks for this great tool, i've been planning to add user functions to my site but it was too much of a hassle, userspice just made it doable in less than a day.
one thing i'm having a problem with rn is connecting to 2 different databases, i've checked the forum and found an old thread for ver4.3 about the same thing, tried that
Quote:$db1 = DB::getDB(['db1name']);

$db2 = DB::getDB(['db2name']);
and this error came up
Quote:SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
i've read around and i think there's something i'm doing wrong when using the code above.
both databases are on the same server and use same user, so that's probably not the problem.
one thing may be important to point out is that the code completely stops executing after the error, the rest of the page doesn't load.

the page i'm using the code on is the users\account.php page, i'm trying to use an external database (different from the one used by userspice) to get and display data.
  Reply
#2
Do both databases have the same username and password and server location?
  Reply
#3
(04-30-2019, 10:12 PM)mudmin Wrote: Do both databases have the same username and password and server location?

thanks for the quick reply, yes they both have the same user and password and are both hosted on the localhost.
  Reply
#4
so i just done some workaround, my project already had a database class that used the same variable and object name used in userspice database class (guessing here, not 100% sure), so i kept it, edited functions and variables names, and used it side by side with the userspice database class.
now the two databases serve completely different purposes so this worked just fine for me, i only had some overlapping data between the two, but i don't think this would be a good solution for people working with more complicated databases
  Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)