0

我有一个用 PHP 编写的teampeak3 机器人,当我启动机器人时出现此错误:PHP 警告:array_column() 期望参数 1 是数组,给定空值...在第 13 行,第 13 行是 $ clientonchannel,我不知道如何使它工作,感谢一些帮助。我是新手。

PHP Code:
    $config['function']['pokeonchannel'] = Array(
        'enable' => true,
        'info' => Array(
            1 => Array(
                'channel' => 20,
                'pokegroup' => Array(103,110),
                'message' => "[NICK] message to user",
            )
        ),
        'interval' => Array('days' => 0, 'hours' => 0, 'minutes' => 0, 'seconds' => 30), //interval
        'datazero' => '1970-01-01 00:00:00'
    );

 foreach($config['function']['pokeonchannel']['info'] as $pokeid)
   {
      $admincount = 0;
      $admincount2 = 0;
      $clientonchannel = array_keys(array_column($user['data'], 'cid'), $pokeid['channel']); **// This is line 13**

 if(isset($clientonchannel[0]))
  { 
    foreach($pokeid['pokegroup'] as $pokegroup)
     {
        $groupclients = $tsAdmin -> serverGroupClientList($pokegroup, $names = true);
             foreach($groupclients['data'] as $clientid)
                 {
                     $client = $tsAdmin -> clientFind($clientid['client_nickname']);
                       if($client['data'])
                                {
                                    $admin = $tsAdmin-> clientInfo($client['data'][0]['clid']);
                                    if(!in_array($admin['data']['cid'], $config['function']['helpchannel']['ignoredonchannel']))
                                    {
                                        $pokemessage = str_replace('[NICK]', $user['data'][$clientonchannel[0]]['client_nickname'], $pokeid['message']);
                                        $tsAdmin -> clientPoke($client['data'][0]['clid'], $pokemessage);
                                        $admincount++;
}
                                    else
                                    {
                                        $admincount2++;
                                    }
                                }
                            }
                        }
                        if($admincount == 0 && $admincount2==1)
                                    {$tsAdmin -> clientPoke($user['data'][$clientonchannel[0]]['clid'], "\n[b]".$language['pokeonchannel']['busy']."[/b]");
                                        return;
                                    }
                                    else if($admincount == 0 && $admincount2>1)
                                    {
                                        $tsAdmin -> clientPoke($user['data'][$clientonchannel[0]]['clid'], "\n[b]".$language['pokeonchannel']['busy2']."[/b]"); 
                                        return;
                                    }
                                    else if($admincount == 0)
                                    {
                                        $tsAdmin -> clientPoke($user['data'][$clientonchannel[0]]['clid'], "\n[b]".$language['pokeonchannel']['lackadministration']."[/b]");    
                                        return;
                                    }
                                    else if($admincount == 1)
                                    {
                                        $tsAdmin -> clientPoke($user['data'][$clientonchannel[0]]['clid'], "\n[b]".$language['pokeonchannel']['aware']."[/b]");
                                        return;
                                    }
                                    else
                                    {
                                        $tsAdmin -> clientPoke($user['data'][$clientonchannel[0]]['clid'], "\n[b]".$language['pokeonchannel']['aware2']."[/b]");
                                        return;
                                    }

                    }
                }
4

1 回答 1

2

我认为变量 $user 不存在。您可以创建一个名为 $user 的变量并在其中获取详细信息。

$sql = "SELECT data FROM users where id = {user id}";
$user = $conn->query($sql);
于 2020-02-26T05:59:59.033 回答