How to fix php Notice:Undefined variable: bd?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
43 views
Why is this happening? Run the script on 000webhost, after run CronJobs, it throws an error. After I go to the site to see what was the matter, and I wrote several of these lines:
Notice:Undefined variable: bd (the destination path of the file) in line 119
Notice:Undefined variable: bd (the destination path of the file) in line 127
Notice:Undefined variable: bd (the destination path of the file) in line 127
Notice:Undefined variable: bd (the destination path of the file) in line 127
And so until they stop CronJobs.
Here is the script where the errors occur:
if (isset($result['response']['ts'])){
$bd = $result['response']['ts'];
print_r($bd);
}
$require_dva = array(
'ts' => $bd
'events_limit' => 1000,
'msgs_limit' => 200,
'v' => '5.76',
'access_token' => $token
);
getme:
$get_params2 = http_build_query($require_dva);
$result2 = json_decode(file_get_contents('https://api.vk.com/method/messages.getLongPollHist...'.$bd.'&msgs_limit=200&events_limit=1000&access_token=*token*'),true);
Please tell me how to solve this problem, I would be very grateful.
by | 43 views

1 Answer

0 like 0 dislike
You have the variable $bd is declared inside the if, but vyzyvaetsya out of it. But because the condition in the if-e is not always true, and $bd is not always declared.
There are two outputs:
1. Preferably. In the beginning of the script $bd:
$bd=array();
2. Turn off the error output. But regular guys don't.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
0 comments
40,796 users