大家好我试图通过post方法发送他的用户名为禁止用户制作脚本。 对于所需的功能,我通过标题中的包含代码导入了所需的文件。
但我有这个错误:
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);
}
?>
答案 0 :(得分:1)
尝试将$ user = $ db-&gt; fetch_array更改为$ db-&gt;查询。
我认为dbal_mysqli没有fetch_array方法。更多信息请访问:http://area51.phpbb.com/docs/code/31x/dbal/dbal_mysqli.html#sql_query()