Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/03/2009, 11:24
kerverin
 
Fecha de Ingreso: febrero-2009
Ubicación: Cusco - Peru
Mensajes: 142
Antigüedad: 15 años, 3 meses
Puntos: 0
Respuesta: conexion MySQL

bueno io mi conexion la realizo de esta forma:
Código PHP:
var $hostname "localhost";
     var 
$database "basedatos";
     var 
$username "user";
     var 
$password "password";
     var 
$conexion;  
     
     
/*---CONSTRUCTOR---*/
     
function conexionbd()
     {  
         if(!isset(
$this->conexion))
        {  
              
$this->conexion mysql_connect($this->hostname$this->username$this->password) or trigger_error(mysql_error(),E_USER_ERROR);
            
mysql_select_db($this->database$this->conexion) or die(mysql_error());
        }  
      }
    
    
/*---FUNCIONES---*/  
    
function consulta($consulta)
    {  
        
$this->total_consultas++;
        
$resultado mysql_query($consulta,$this->conexion);
        if(!
$resultado)
        {
            echo 
'MySQL Error: '.mysql_error();
            exit;
        }
        return 
$resultado;
    } 
Espero te sirva