Catchable fatal error: Argument 1 passed to RedBeanPHP \ Util \ DispenseHelper :: dispense () must be an instance of RedBeanPHP \ OODB, null given

This is the error in RedBeanPHP. Trying to create a users table in the database with this method:

 $data = $_POST; $user = R::dispense('users'); $user->login = $data['login']; $user->password = $data['password']; $user->email = $data['email']; R::store($user); 

Already cleaned everything up, and added it, and re-connected the database a hundred times. By the way here is the connection

 <?php require 'rb.php'; R::setup('mysql:host=localhost; dbname=baza','root',''); ?> 

What could be the problem?(

Closed due to the fact that it is off-topic by entithat , 0xdb , aleksandr barakin , Dmitry Kozlov , Kosta B. participants . Jan 21 at 10:17 pm .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - entithat, 0xdb, aleksandr barakin, Dmitry Kozlov, Kosta B.
If the question can be reformulated according to the rules set out in the certificate , edit it .

    1 answer 1

    Thanks great people for help.

    I decided myself. The error, as I understand it, indicates problems with connecting the rb.php file and the location of the code that connects the database (using the exception method I tried everything until I came to this conclusion)

    Solved the problem like this:

    rb.php connected to the main file

     require_once 'rb.php'; 

    Previously, it was generally different, rb.php was connected to database.php, but it was already connected to the main file, having the path libs / database.php. Karoche full stuffing.

    And lastly moved

     R::setup('mysql:host=localhost; dbname=yourname','root',''); 

    Connection code to the database in the main file

    By the way, nowhere on the Internet found a solution to this problem: with