I have a teamspeak3 bot written in PHP and when i ty to start the bot i get this error: PHP Warning: array_column() expects parameter 1 to be array, null given... on line 13,and the line 13 is the $clientonchannel, i don't know hot to make'it work, some help is appreciated. Im new with this.
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;
}
}
}
I think variable $user does not exist. you can make a variable called $user and fetch details in it.
$sql = "SELECT data FROM users where id = {user id}";
$user = $conn->query($sql);