Error, can't create table

288 views
Skip to first unread message

x.dj...@mail.ru

unread,
Jan 27, 2017, 9:35:56 AM1/27/17
to redbeanphp
Error:

Catchable fatal error: Argument 1 passed to RedBeanPHP\Util\DispenseHelper::dispense() must be an instance of RedBeanPHP\OODB, null given, called in Z:\home\test2.ru\www\libs\rb.php on line 10715 and defined in Z:\home\test2.ru\www\libs\rb.php on line 12642


Code:
<?php 
require "libs/rb.php";
$data = $_POST;
if (isset($data['do_signup'])) {
//регестрируем
    $errors = array();
    if( trim($data['login']) == '' )
    {
        $errors[] = 'Введите логин';
    }
    if( trim($data['email']) == '' )
    {
        $errors[] = 'Вы не ввели email';
    }
    if( $data['password'] == '' )
    {
        $errors[] = 'Вы не ввели пароль';
    }
    if( $data['password_2'] == '' )
    {
        $errors[] = 'Вы не ввели повторный пароль';
    }
    if( $data['password_2'] != $data['password']  )
    {
        $errors[] = 'Повторный пароль введён не верно';
    }
    if( empty($errors) ) {
        //Можно регестрировать
        $user = R::dispense('users');
        $user->login = $data['login'];
        $user->email = $data['email'];
        $user->password = $data['password'];
        R::store($user);
        echo '<div id="erorrs">Регистрация прошла успешно!</div><hr>';
    } else {
        echo '<div id="erorrs">'.array_shift($errors).'</div><hr>';
    }
}
?>
<style>
.form_reg {
    width: 400px;
    height: 500px;
    background-color: #141414;
    margin: 10% auto;
    color: #fff;
}
button {
    color: #000;
}
</style>
<form action="/signup.php" method="POST" class="form_reg">
Введите логин:<br>
<input type="text" name="login" value="<?php echo @$data['login']; ?>"><br>
Введите e-mail:<br>
<input type="text" name="email" value="<?php echo @$data['email']; ?>"><br>
Введите пароль:<br>
<input type="password" name="password"><br>
Введите Ваш пароль повторно:<br>
<input type="password" name="password_2"><br>
<button type="submit" name="do_signup">Зарегестрироваться</button>
</form>

Matthew Frederico

unread,
Jan 27, 2017, 2:36:20 PM1/27/17
to redbe...@googlegroups.com
I don't see where you are setting up your database:
For example:

R::setup('mydatabase.sqlite');
or
R::setup(mysql:localhost;port=3306;dbname=mydatabase;",'dbuser','dbpass');


--
You received this message because you are subscribed to the Google Groups "redbeanphp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redbeanorm+unsubscribe@googlegroups.com.
To post to this group, send email to redbe...@googlegroups.com.
Visit this group at https://groups.google.com/group/redbeanorm.
For more options, visit https://groups.google.com/d/optout.



--
-`;'- Matthew Frederico

dimakly...@gmail.com

unread,
Jul 10, 2018, 5:33:07 PM7/10/18
to redbeanphp
Ошибка скорее всего тут: require "libs/rb.php"; если подключаете rb.php в другом php файле допустим в db.php где код <?php

require "libs/redbean/rb.php"; //путь к библиотеке rb.php
R::setup( 'mysql:host=localhost;dbname=basename',
        'root', '123' ); ?> 
то в этом php файле, необходимо подключать не rb.php, а db.php ---> require "includes/db.php"; //путь к нему

Reply all
Reply to author
Forward
0 new messages