Salve a tutti, premetto che non sono un programmatore ma me la cavo nelle modifiche di codice, non a livelli eccelsi ma riesco a fare funzionare quello che serve tranne in questo caso.

Sto migrando e di conseguenza modificando il mio gestionale da PHP 5 a PHP 8.2, ne ho gia fatto un buon 90% ma qui mi sono bloccato.

Ho questo codice:

Codice PHP:
<?php
class MySQL {
  var 
$host;
  var 
$user;
  var 
$password;
  var 
$database;
  var 
$connessione;
  var 
$errore;

  function 
MySQL ($host,$user,$password,$database)
  {
    
$this->host=$host;
    
$this->user=$user;
    
$this->password=$password;
    
$this->errore=$database;
    
$this->connessione();
  }

  function 
connessione()
  {
    if (!
$this->connessione = @mysqli_connect($this->host$this->user$this->password))
    {
      
trigger_error('Impossibile connettersi a MySQL.');
      
$this->errore=true;
    }
    elseif (!@
mysqli_select_db($this->errore,$this->connessione))
    {
      
trigger_error('Impossibile connettersi al database.');
      
$this->errore=true;
    }
  }
 
  function 
notifica_errore()
  {
    if (
$this->errore) return true;
    
$notifica=mysqli_error($this->connessione);
    if (empty(
$notifica)) return false;
    else return 
true;
  }
  
  function 
query($sql)
  {
    if (!
$qRes=mysqli_query($this->connessione$sql))
    
trigger_error (
    
'Query fallita: '.mysqli_error($this->connessione).
    
' SQL: '.$sql);
    return new 
MySQLResult($this,$qRes);
  }
}
  
class 
MySQLResult
{
  var 
$mysql;
  var 
$query;
  function 
MySQLResult(& $mysql,$query)
  {
    
$this->mysql=& $mysql;
    
$this->query=$query;
  }

  function 
fetch()
  {
    if (
$f=mysqli_fetch_array($this->query,mysqli_ASSOC))
    {
      return 
$f;
    }
    elseif (
$this->size() > 0)
    {
      
mysqli_data_seek($this->query,0);
      return 
false;
    }else{
      return 
false;
    }
  }
  
  function 
size()
  {
    return 
mysqli_num_rows($this->query);
  }
  
  function 
insertID()
  {
    return 
mysqli_insert_id($this->mysql->connessione);
  }
  
  function 
notifica_errore()
  {
    return 
$this->mysql->notifica_errore();
  }
}
?>
Che viene richiamato con @require('mysql.php'); da index2.php

questo codice mi da il seguente errore:

Fatal error: Uncaught TypeError: mysqli_query(): Argument #1 ($mysql) must be of type mysqli, null given in /membri/zippo1978/cmsassistenza2/carrello/mysql.php:47 Stack trace: #0 /membri/zippo1978/cmsassistenza2/carrello/mysql.php(47): mysqli_query(NULL, 'SELECT * FROM l...') #1 /membri/zippo1978/cmsassistenza2/carrello/index2.php(509): MySQL->query('SELECT * FROM l...') #2 {main} thrown in /membri/zippo1978/cmsassistenza2/carrello/mysql.php on line 47


La linea 47 è
Codice PHP:
if (!$qRes=mysqli_query($this->connessione$sql)) 

mentre nel file index2.php la linea 509 è
Codice PHP:
$res $db->query($sql); 

che è parte del codice

Codice PHP:
//cerca per ean o codice 
$ean $_POST['ean'];
$sql "SELECT * FROM listinoaltri where ean='$ean'"  ;
$sql2 "SELECT * FROM eancode where barcode='$ean'"  ;
$sql3 "SELECT * FROM listifu where Cdpar='$ean'"  ;
$sql4 "SELECT * FROM barcode where barcode='$ean'"  ;
$res $db->query($sql);
$res2 $db->query($sql2);
$res3 $db->query($sql3);
$res4 $db->query($sql4);
$f['prezzov'] = str_replace(",""."$f['prezzov']);
$f['Preze'] = str_replace(",""."$f['Preze']);
while (
$f $res->fetch())
{
    
$f['prezzov'] = str_replace(",""."$f['prezzov']);
  
$result1[] = ''.$f['codice']. '';


Mi serve una mano per risolvere questo problema, grazie