MyBB Community Forums

Full Version: How to connect with other database
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
How to connect with other database in mybb maybe using $db->connect(); or $db->select_db please give me example i have 2 db on same server, i need fast replies.
Depends what and how you are going to connect db. Here's a simple query used to "connect" to a "users" table.
$db->simple_select("users" , "*" "uid='{$mybb->user['uid']}'", array('limit' => 1));
I wrote some script and he is downloading data from other base, he doesn't want to download data from the mybb base
I didn't understand what you are trying to explain, sorry.. but.
sorry I used translator Toungue

I have 2 databases

-----------------
database_mybb
database_myscript
-----------------
"database_mybb" is default mybb database. I insert my script into mybb and I need PM function, but i used mysql_query("") not $db->query(); I need connect to database_myscript with $db.

I have errors, how to use $db->connect(); to connect database_myscript and insert query?
To connect to database, you have to use the following;
$db->simple_select();

To insert any value into the database, you can use the following;
$db->insert_query();
(2011-01-04, 06:10 PM)Yaldaram Wrote: [ -> ]To connect to database, you have to use the following;
$db->simple_select();

To insert any value into the database, you can use the following;
$db->insert_query();

No, that simply connects to the database defined in the mybb config.

He wants to connect to a separate db. For that, you will need to use pure PHP. Just rite a class in standard PHP and then include it as $mydb-> or something. Same funcitonality. But you wont be able to use $db Sad
(2011-01-04, 06:02 PM)kreteda Wrote: [ -> ]I need connect to database_myscript with $db.

Undecided
sorry man, i don't understand.

can U create code ?
$sql = mysql_connect ("localhost","ptmclan_mybb2","MYPASSWORD")
or die ("error");
$db= mysql_select_db("ptmclan_nfsw", $sql)
or die ("error");

Please.
Use this one;
$sql = mysql_connect("localhost","ptmclan_mybb2","MYPASSWORD")
if (!$sql)
{
 die('Not connected : ' . mysql_error());
}
$db = mysql_select_db("ptmclan_nfsw", $sql)
if (!$db)
{
die('Not connected : ' . mysql_error());
}
Pages: 1 2