Ciao ragazzi, ho un problema e non capisco dove sbaglio. Allora ho creato una classe in file php e all'interno di questa classe ho dichiarato diverse variabili tra cui queste due:
	
	
	
		
nella classe  ho definito vari metodi tra cui questo:
	
	
	
		
poi ho creato il file composizione.php che è il seguente:
	
	
	
		
 nel file composizione.php mi viene dato questo errore Fatal error: Call to a member function Query() on null sulla riga 21, che sarebbe $this->db->Query($query);
Cosa sbaglio? Non riesco a trovare l'errore.
				
			
		PHP:
	
	var $qid;
var $Error;
	
		PHP:
	
	public function Query($query)
    {
        $this->qid = mysql_query($query);
        if (!$this->qid) {
            $this->Error .= mysql_error() . ",<br> $query \n";
            $this->Error();
        }
        return $this->qid;
    }
	
		PHP:
	
	<?php
class composizione
{
    var $ricetta;
    var $ingrediente;
    var $quantita;
    var $db;
    public function composizone($db)
    {
        $this->ricetta=0;
        $this->ingrediente=0;
        $this->quantita=0;
        $this->db=$db;
    }
 
    public function aggiungi($ingrediente, $ricetta, $quantita)
    {
        $query="INSERT INTO composizione (ingrediente, ricetta, quantita')
               VALUES (".$ingrediente.", ".$ricetta.", ".$quantita.")";
        $this->db->Query($query);
    }
}
?>
	Cosa sbaglio? Non riesco a trovare l'errore.
			
				Ultima modifica di un moderatore: