Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Conexion{
- var $variable;
- //constructor de la clase
- function Conexion(){
- }
- function getVariable(){
- return $this->variable;
- }
- function conectar(){
- if(!($con=@mysql_connect("localhost","usuario","clave"))){
- echo "error al conectar la base de datos";
- exit();
- }else{
- //echo "conexion exitosa<br>";
- }
- if(!@mysql_select_db("database",$con)){
- echo "error al seleccionar la base de datos";
- exit();
- }else{
- //echo "seleccion de base de datos exitosa<br>";
- }
- $this->variable=$con;
- return true;
- }
- }
- $conn = new Conexion();
- if($conn->conectar()==true){
- echo "se puede conectar";
- }else{
- echo "no se puede conectar";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement