连接到数据库后,我将开放服务器与RedBean PHP一起使用。当我尝试创建表时,出现错误:
致命错误:消息为“无法连接到数据库(SOT)”的未捕获异常“ PDOException”。在C:\ Users \ george \ OSPanel \ domains \ divinehunt.com \ rb.php:1011中堆栈跟踪:#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 table',Array)#2 C:\ Users \ george \ OSPanel \ domains \ divinehunt.com \ rb.php(1056):RedBeanPHP \ Driver \ RPDO-> GetAll('show table',Array)#3 C:\ Users \ george \ OSPanel \ domains \ divinehunt.com \ rb.php(4183):RedBeanPHP \ Driver \ RPDO-> GetCol('显示表格',数组)#4 C:\ Users \ george \ OSPanel \ domains \ divinehunt.com \ rb.php(6652 ):RedBeanPHP \ Adapter \ DBAdapter-> getCol('显示表格')#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):在Li上的C:\ Users \ george \ OSPanel \ domains \ divinehunt.com \ rb.php中ne 1111
在此脚本中,我将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');
> }
>
> }
> ?>
非常感谢