View Single Post
Old 16-05-2004, 22:53   #1
bprogram
Member
 
Iscritto dal: May 2002
Messaggi: 63
[PHP]mysql_select_db e classe

in questa classe

Codice PHP:
<?php
    
//=> [Classificazione] Classe Generale da inserire solamente
   //    nell'index.php dove verrano richiamati tutti gli altri file
  //     di FMP
 
  //=> MySQL Db Classes
class MySQL {
 
  
//**Database connect and Select**
 
var $dbhost
 var 
$dbuser
 var 
$dbpass
 var 
$dbname
 var 
$dbhost
 var 
$dbuser
 var 
$dbpass
 var 
$dbname;
 var 
$db_prefix;
 var 
$query;
 var 
$fetcharray;
 var 
$conn;
 var 
$select;
  
//**Database Error's**
 
var $is_error;
 var 
$msg_error;     

 function 
MySQL $dbhost '',  $dbuser '',  $dbpass '',  $dbname ''){

 
/*$this->host = (string)   $dbhost;
 $this->dbuser = (string) $dbuser;
 $this->dbpass = (string) $dbpass;
 $this->dbname = (string) $dbname;*/
 
$this->is_error FALSE;
 
$this->msg_error '';     

 
//return is_resource( $this->Connect() ) ? $this->Connect() : null;
 
}


function 
Connect($dbhost '',  $dbuser '',  $dbpass ''$dbname ''){

 
$this->host = (string)   $dbhost;
 
$this->dbuser = (string) $dbuser;
 
$this->dbpass = (string) $dbpass;
 
$this->dbname = (string) $dbname;
 
$this->is_error FALSE;
 
$this->msg_error ''

 
$this->conn mysql_connect($this->host,$this->dbuser,$this->dbpass);
 
$this->select mysql_select_db('cittaitnernet_config',$this->conn);

  if( 
is_resource($this->conn) )
 {
 echo 
$this->dbname;
  
$this->select mysql_select_db('cittaitnernet_config',$this->conn);
 }     
 else
 {
     
$this->is_error TRUE;
     
$this->msg_error 'connessione fallita'.mysql_errors;     
      return(
0);
 }


 
 return 
$this->conn;
 return 
$this->select;

}

  

    function 
query($query NULL)
    {
    
     
$this->query = (string) $query;
     
     if ( 
is_resource$this->Connect() ) )
     {     
     
        
$this->query mysql_query($this->query,$this->Connect());
         if (! 
is_resource($this->query))
         {
             
$this->is_error TRUE;
             
$this->msg_error mysql_error();     
        
        }   
     }
    else
     {
         
$this->is_error TRUE;
         
$this->msg_error 'connessione fallita ';     
     }     
     
      return 
$this->query;
    
    }

    function 
fetcharray($fetcharray NULL)
    {
    
     if (!
is_resource($fetcharray)) {
          
$this->is_error TRUE;
          
$this->msg_error 'risorsa non valida';
          return 
FALSE;
         }

         
$this->fetcharray $fetcharray;

     
     if ( 
is_resource$this->Connect() ) )
     {     
     
        
$this->fetcharray mysql_fetch_array($this->fetcharray);
         if (! 
is_resource($this->fetcharray))
         {
             
$this->is_error TRUE;
             
$this->msg_error mysql_error();     
        
        }   
     }
    else
     {
         
$this->is_error TRUE;
         
$this->msg_error 'connessione fallita';     
     }     
     
      return 
$this->fetcharray;
    
    }

        function 
close () {

        
mysql_close($this->Connect());     
        
        }
   
}
?>
Funziona tutto benissimo, tranne che il mysql_select_db, nn vuol funzionare in alcunissimo modo, il bello e che se scrivo ad esempio mysqlssss_select_db, mi da l'errore che dice che nn è una funzione riconoscita, e anke altre scemarie, pero, nn fa proprio il select -.-, secondo voi perke ?
bprogram è offline   Rispondi citando il messaggio o parte di esso