使用RedBean php连接数据库时出现问题

时间:2019-03-13 07:30:43

标签: php mysql database redbean

我在RedBean PHP中使用开放服务器。连接到数据库后,当我尝试创建表时,出现错误:

Fatal error: Uncaught exception 'PDOException' with message 'Could not connect to database (sots).' 
in C:\Users\george\OSPanel\domains\divinehunt.com\rb.php:1011 
Stack trace: 
#0 C:\Users\george\OSPanel\domains\divinehunt.com\rb.php(735): RedBeanPHP\Driver\RPDO->connect() 
#1 C:\Users\george\OSPanel\domains\divinehunt.com\rb.php(1035): RedBeanPHP\Driver\RPDO->runQuery('show tables', Array) 
#2 C:\Users\george\OSPanel\domains\divinehunt.com\rb.php(1056): RedBeanPHP\Driver\RPDO->GetAll('show tables', Array) 
#3 C:\Users\george\OSPanel\domains\divinehunt.com\rb.php(4183): RedBeanPHP\Driver\RPDO->GetCol('show tables', Array) 
#4 C:\Users\george\OSPanel\domains\divinehunt.com\rb.php(6652): RedBeanPHP\Adapter\DBAdapter->getCol('show tables') 
#5 C:\Users\george\OSPanel\domains\divinehunt.com\rb.php(5857): RedBeanPHP\QueryWriter\MySQL->getTables() 
#6 C:\Users\george\OSPanel\domains\divinehunt.com\rb.php(8912): RedBeanPHP\QueryWriter\AQueryWriter->tableExists('acounts') 
#7 C:\Users\george\OSPanel\domains\divinehunt.com\rb.php(9014): Re in C:\Users\george\OSPanel\domains\divinehunt.com\rb.php on line 1011

在此脚本中,我将redbean连接到数据库:

<?php
require "rb.php";   

R::setup( 'mysql:host=localhost;dbname=sots',
        'mysql ', 'mysql' );
 ?>

当您单击表单中的按钮时,将执行该操作:

<?php session_start(); require_once "db.php";
> 
> $data=$_POST; if (isset($data['do_regis'])) {
>     $user= R::dispense('acounts');
>     $user->login=$data['login'];
>     R::store($user);
>     $dir=$data['login'];
>     if (is_dir($dir)==false) {
>       mkdir('Accounts/'.$dir);
>       mkdir('Accounts/'.$dir.'/Postes');
>       mkdir('Accounts/'.$dir.'/Photos');
>     }
> 
> }
> ?>

0 个答案:

没有答案