Answer the question
In order to leave comments, you need to log in
After connecting 2 db, the code (RedBean) does not work?
I connect 2 DB
<?php
require 'engine/lib/rb.php';
R::setup('mysql:host=localhost;dbname=sait',
'root',''); //База данных сайта
R::addDatabase('DB1','mysql:host=localhost;dbname=server',
'root','',$server); //База данных сервера #1
R::selectDatabase('DB1');
R::selectDatabase('default');
if(!R::testconnection())
{
exit ('Нет соединения с базой данных');
}
session_start();
?>
<?php
R::selectDatabase('DB1');
$users = R::getAll( 'SELECT * FROM accounts WHERE `online` >=0 AND `admin` >= 1' );
foreach ($users as $user)
{
$id = $user['id'];
$user = R::load('accounts', $id);
echo('<a href="nickname.php?iddb='.$user[id].'">');
echo('<li type="1">[LVL '.$user[admin].'] '.$user[Name].'(ONLINE: '.$user[online].')</li>');
echo('</a>');
var_dump($users);
}
?>
Answer the question
In order to leave comments, you need to log in
Turn on error display or read the logs. where did this $server variable come from?
$user[id]
$user[admin]
$user[Name]
what's with the weird syntax for accessing an array element?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question