'PHP Parse error: syntax error, unexpected variable "$link_id", expecting ")" in file | error

I'm new to PHP and I tried to make the code at the very bottom work but I can't make it work so I'm asking for help here. so please help me

php version i use: 8.1.2

errors i get while i try to load the page with the code:

[Thu Feb 17 12:51:36.272143 2022] [proxy_fcgi:error] [pid 473273] [client (ip)] AH01071: Got error 'PHP message: PHP Parse error: syntax error, unexpected variable "$link_id", expecting ")" in /var/www/legionbooter/public_html/lib/class_db.php on line 86'

[Thu Feb 17 12:52:21.093521 2022] [proxy_fcgi:error] [pid 473263] [client (ip)] AH01071: Got error 'PHP message: PHP Parse error: syntax error, unexpected variable "$database", expecting ")" in /var/www/legionbooter/public_html/lib/class_db.php on line 86'

the /var/www/legionbooter/public_html/lib/class_db.php file (the code that doesn't work): https://pastebin.com/Es33qTiw



Solution 1:[1]

  1. remove comma - function select_db($link_id, $database**,**)
  2. first parameter should be connection and second should be database name, so correct this line also - if (!$this->select_db($this->database, $this->link_id))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Isha