phpbb ban脚本中未定义的方法dbal_mysqli::fetch_array()
嗨,伙计们,我试图通过post方法发送他的用户名,为ban用户制作一个脚本。 对于所需的函数,我通过头中的include代码导入了所需的文件 但我有一个错误:phpbb ban脚本中未定义的方法dbal_mysqli::fetch_array(),php,mysqli,phpbb,phpbb3,Php,Mysqli,Phpbb,Phpbb3,嗨,伙计们,我试图通过post方法发送他的用户名,为ban用户制作一个脚本。 对于所需的函数,我通过头中的include代码导入了所需的文件 但我有一个错误: Fatal error: Call to undefined method dbal_mysqli::fetch_array() in C:\xampp\htdocs\phpBB3\ban.php on line 25 我的代码是: <?php $phpbb_root_path = '../phpbb3/'; define('I
Fatal error: Call to undefined method dbal_mysqli::fetch_array() in C:\xampp\htdocs\phpBB3\ban.php on line 25
我的代码是:
<?php
$phpbb_root_path = '../phpbb3/';
define('IN_PHPBB', true);
define('IN_CHECK_BAN', 1);
define('IN_LOGIN', 1);
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
if ( !function_exists('group_memberships') )
{
include_once($phpbb_root_path . 'includes/functions_user.'.$phpEx);
}
if ( $_SERVER['REQUEST_METHOD'] === 'POST' )
{
$username = '';
$post = file_get_contents( "php://input" );
sscanf( $post, "%s", $username);
}
$query = "SELECT user_id, username FROM phpbb_users WHERE username = '" . $db->sql_escape($username) . "'";
$user = $db->fetch_array($query);
$sql = 'SELECT FROM phpbb_banlist WHERE ban_userid = ' . $user['uid'] . '';
if($db->fetch_field($sql, "ban_userid"))
{
// $errors[] = "user alredy banned";
}
else
{
$insert_array = array(
'ban_userid' => $user['uid'],
'ban_start' => (int) $current_time,
'ban_end' => (int) $ban_end,
'ban_exclude' => (int) $ban_exclude,
'ban_reason' => (string) $ban_reason,
'ban_give_reason' => (string) $ban_give_reason,
);
$db->insert_query('phpbb_banlist', $insert_array);
}
?>
尝试将$user=$db->fetch\u数组更改为$db->query
我认为dbal_mysqli没有fetch_数组方法。此处的更多信息:但我需要数组从$query返回用户名和用户id。那么你认为我该怎么做呢?你使用的是一个奇怪的模块(dbal_mysqli),它本机不支持数组,但它的父类dbal有一个名为“sql_fetchrowset”的数组返回方法,那么你可以试试吗?如果可以,我认为适合您的库应该是(dbal_mysql)。