Advertisement
Guest User

Untitled

a guest
Sep 8th, 2010
860
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2.     class Conexion{
  3.         var $variable;
  4.         //constructor de la clase
  5.         function Conexion(){
  6.             }
  7.         function getVariable(){
  8.                 return $this->variable;
  9.             }
  10.         function conectar(){
  11.                 if(!($con=@mysql_connect("localhost","usuario","clave"))){
  12.                         echo "error al conectar la base de datos";
  13.                         exit();
  14.                     }else{
  15.                             //echo "conexion exitosa<br>";
  16.                         }
  17.                     if(!@mysql_select_db("database",$con)){
  18.                             echo "error al seleccionar la base de datos";
  19.                             exit();
  20.                         }else{
  21.                                 //echo "seleccion de base de datos exitosa<br>";
  22.                             }
  23.                     $this->variable=$con;
  24.                     return true;
  25.             }
  26.     }
  27.    
  28. $conn = new Conexion();
  29. if($conn->conectar()==true){
  30.     echo "se puede conectar";
  31. }else{
  32.     echo "no se puede conectar";
  33. }
  34.  
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement