Salve giovani...
X chi ha voglia di perdere un pò di tempo.. posto 2 classi.. se gentilmente qualcuno le controlla e mi dice xke non funzionano e magari mi dà anche qualche consiglio..

Classe x la connesione al database:
Codice PHP:
class database {

    var 
$resource;
    var 
$query;


    function 
database($host$user$password$db) {
        
$connessione mysql_connect($host$user$password);
        if (!
$connessione) {
            
$this->error_msg();
        }

        
$this->resource mysql_select_db($db$connessione);
        if (!
$this->resource) {
            
$this->error_msg();
        }
        return 
$this->resource;
    }

    function 
set_query($sql$offset 0$limit 0) {
        
$this->sql $this->escaped($sql);
        
$this->offset intval($offset);
        
$this->limit intval($limit);

        if (
$this->limit || $this->offset 0) {
            
$this->sql .= "\nLIMIT $this->offset$this->limit";
        }

        
$this->query mysql_query($this->sql);
        if (!
$this->query) {
            
$this->error_msg();
        }
        return 
$this->query;
    }

    function 
array_campi() {
        
$campi = array();
        while (
$row mysql_fetch_assoc($this->query)) {
            
$campi[] = $row;
        }
        
mysql_free_result($this->query);
        return 
$campi;
    }

    function 
get_affected_rows() {
        echo 
mysql_affected_rows($this->resource);
    }

    function 
indice_riga() {
        
$ret null;
        if (
$row mysql_fetch_row($this->query)) {
            
$ret $row[0];
        }
        
mysql_free_result($this->query);
        return 
$ret;
    }

    function 
array_colonne($colonna) {
        
$valore = array();
        while (
$row mysql_fetch_row($this->query)) {
            
$valore[] = $row[$colonna];
        }
        
mysql_free_result($this->query);
        return 
$valore;
    }

    function 
carica_lista_associata($key='') {
        
$array = array();
        while (
$row mysql_fetch_assoc($this->query)) {
            if (
$key) {
                
$array[$row[$key]] = $row;
            } else {
                
$array[] = $row;
            }
        }
        
mysql_free_result($this->query);
        
print_r($array);
    }

    function 
get_num_rows() {
        return 
mysql_num_rows($this->query);
    }

    function 
prima_riga() {
        
$riga null;
        if (
$row mysql_fetch_row($this->query)) {
            
$ret $row;
        }
        
mysql_free_result($this->query);
        
print_r($riga);
    }

    function 
escaped($text) {
        if (
version_compare($this->get_version(), '4.3.0''<')) {
            
$string mysql_escape_string($text);
            } else {
            
$string mysql_real_escape_string($text);
        }
        return 
$string;
    }

    function 
error_msg() {
        return 
mysql_error();
    }

    function 
get_version() {
        return 
mysql_get_server_info($this->resource);
    }

Qui vorrei capire xke se io in un file tipo config.inc ho le variabili $host, $pass, $db e $user non mi fà la connessione.. se pero metto i valori all'interno della classe funziona??? e poi qualche suggerimento..

La seconda:
Codice PHP:
class stato extends database {

    var 
$nickname;

    function 
stato() {
        
parent::database();
    }

    function 
inserimento_tabella($nickname) {
        
$this->nickname $nickname;
        if (
$this->controllo_doppio()) {
            
$sql "INSERT INTO stato VALUES ('', '" $this->nickname "', '1', NOW())";
            
$this->set_query($sql);
            echo 
"inserito!!!";
            } else {
            return 
$this->errore();
        }
    }

    function 
controllo_doppio() {
        
$sql "SELECT nickname_utente FROM stato WHERE nome_utente = $this->nickname";
        if (
$this->set_query($sql)) {
            
$this->errore();
            return 
FALSE;
            } else {
            return 
TRUE;
        }
    }

    function 
errore() {
        echo 
"C'è stato un'errore: " mysql_error();
    }

Xke se faccio:

$db = new database;
$stato = new stato;
$stato->inserimento_tabella("Mindex");

mi dice inserito!!! ........ ma non inserisce niente nella tabella????

Ki ha voglia di scervellarsi e di tirarmi le orecchie ben venga.. non mi aspetto aiuti..
Grazieeeeeee