2

I have a php bot (on IRC), and since I updated my php and mysql to the last version on CentOS I've come across with 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);
            }
        }

Line with error

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

1 Answer 1

1

You need to check the existance of the keys you have in the array before comparing as it can not find it anyway.

use this instead

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

also for this will be good to avoid any further problems

if (isset($voices["#pthelp"]['count']) &&  $voices["#pthelp"]['count'] > 0)
Sign up to request clarification or add additional context in comments.

2 Comments

Hey @KhaledHassan thank you, one more question, at the end of the code i've: unset ($value); $ops_count = ($ops["#pthelp"]['count'] ? $ops["#pthelp"]['count'] : 0); $voices_count = ($voices["#pthelp"]['count'] ? $voices["#pthelp"]['count'] : 0); and got the same error, can you help me?
Hi @Fdcarvalho , can you please edit your main post in order to understand what is the problem correctly regarding what do you unset and what error cause at which line and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.