Why is the class swearing to the property?

Hello, there is a method in a class that requires a database connection.
public $db_connect; Set the property 
public function __construct($db_connect) Set the parameter for the constructor
$this->connect = $db_connect;
$file = __DIR __ . '/log.txt',
file_put_contents($file, mysqli_get_server_info($this->connect)) Trying to find out the version of the database

throws a flurry of errors 
PHP Warning: Missing argument 1 for VKNotification::__construct(), called in
 PHP Notice: Undefined variable: db_connect in
 mysqli_get_server_info() expects parameter 1 to be mysqli, null given in 
PHP Warning: Missing argument 1 for VKNotification::__construct(), called in
 PHP Notice: Undefined variable: db_connect in

Data $db_connect pass from another file
$db_connect = mysqli_connect('localhost', '045855087_11', '-6Rh~=c73\5.', 'one_123');

It is connected and the autoloader (if it matters).
The error seems to indicates that one argument, but I can't figure how to fix it and waiting for help from you. Thank you
June 3rd 19 at 19:14
2 answers
June 3rd 19 at 19:16
Solution
As the constructor is called?
if ($this->config['group_join']['avatar']) {
 if (!strpos($user_info, '<foaf:img>') || preg_match('/https?:\/\/vk\.com\/images\/camera_50\.gif/iU', $user_info))
 return ;
 }</foaf:img>
- josi commented on June 3rd 19 at 19:19
use the code formatting - Birdie_Jones92 commented on June 3rd 19 at 19:22
fixed - josi commented on June 3rd 19 at 19:25
And where you here the class is called, I don't see - Icie_Von commented on June 3rd 19 at 19:28
You mean this?
$notification = new VKNotification($vkapi, $config);
- josi commented on June 3rd 19 at 19:31
,
$notification = new VKNotification($vkapi, $config, $db_connect);

Try - Birdie_Jones92 commented on June 3rd 19 at 19:34
Yes , only that sending this piece of thought that I don't pass the third argument. Everything works Thank you all - josi commented on June 3rd 19 at 19:37
June 3rd 19 at 19:18
"$db_connect" != "$this->connect"
the prefix db_?
db = data base
"$db_connect" != "$this->connect"

This decision? - josi commented on June 3rd 19 at 19:21
the hint property, you have a different name - Birdie_Jones92 commented on June 3rd 19 at 19:24
The prefix db_ added. Now $this->db_connect = $db_connect, but nothing is working - josi commented on June 3rd 19 at 19:27
that means there is still an error or you have salad made from different places in the code that the task is not clear how to decide what you showed is an obvious mistake that you are trying to write to the property which you have, and then read a property which you do not - Icie_Von commented on June 3rd 19 at 19:30
,
class VKNotification {
/**
 * @var VKAPI class Instance for working with VK API with a key group access
*/
 private $vkapi;
/**
 * @var array Configuration
*/
 private $config;
/**
 * @var string the dB Connection
*/
 private $db_connect;

/**
 * Designer
*
 * @param VKAPI $vkapi an instance of the class VKAPI with a key group access
 * @param array $config Configuration
*/
 public function __construct(VKAPI $vkapi, array $config, $db_connect) {
 $this->vkapi = $vkapi;
 $this->config = $config;
 $this->db_connect = $db_connect;

 }

Without the $db_connect in the designer everything works. I don't know what's wrong - josi commented on June 3rd 19 at 19:33

Find more questions by tags PHP