0){foreach($ops["#pthelp"]as$valu"> Trying to access a null type value using array offset-PHP Chinese Network Q&A
Trying to access a null type value using array offset
P粉334721359
P粉334721359 2023-08-25 09:40:08
0
1
515

I have a php bot (on IRC) and since I updated php and mysql to the latest versions of CentOS, I'm getting this error

unset($ops_activos); unset($voices_activos); if ($on_pthelp == 1) { if ($ops["#pthelp"]['count'] > 0) { foreach ($ops["#pthelp"] as $value) { if (!is_int($value)) { if (isset($ops_activos)) { $ops_activos .= " " . $value; } else { $ops_activos = $value; } } } if ($bot_debug) { scmd("PRIVMSG ". $log_chan ." :[Membros (Mode)] [OPS]: ". $ops_activos); } } unset ($value); if ($voices["#pthelp"]['count'] > 0) { foreach ($voices["#pthelp"] as $value) { if (!is_int($value)) { if (isset($voices_activos)) { $voices_activos .= " " . $value; } else { $voices_activos = $value; } } } if ($bot_debug) { scmd("PRIVMSG ". $log_chan ." :[Membros (Mode)] [VOICES]: ". $voices_activos); } }

Error line

if ($ops["#pthelp"]['count'] > 0) {

P粉334721359
P粉334721359

reply all (1)
P粉268654873

Before comparing you need to check if the key you have exists in the array because it won't find it anyway.

Please use the following code instead:

if (isset($ops["#pthelp"]['count']) && $ops["#pthelp"]['count']> 0)

Also, doing this will avoid any further problems.

if (isset($voices["#pthelp"]['count']) && $voices["#pthelp"]['count'] > 0)
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!