Return to Snippet

Revision: 30439
at August 14, 2010 00:18 by yeremiloli


Updated Code
<php
/**
* Simple Class Connect
*/

class Connect {
     
     var $host="localhost";
     var $dbname="yourdatabase"; 
     var $usuario="userserver"; 
     var $password="passwordserver";
     var $link;
     var $unlink;

     function onServer()
     {
          $this->link = mysql_connect($this->host, $this->usuario, $this->password);
          $this->database = mysql_select_db($this->dbname);
     }
     
     
     function offServer()
     {
          $this->unlink = mysql_close($this->link);
     }

}

$var = new Connect();
$var->onServer();
  echo 'run your queries here';
$var->offServer();
?>

Revision: 30438
at August 13, 2010 23:52 by yeremiloli


Initial Code
<php
/**
* Simple Class Connect
*/

class Connect {
     
     var $host="localhost";
     var $dbname="yourdatabase"; 
     var $usuario="userserver"; 
     var $password="passwordserver";

     function onServer()
     {
          $link = mysql_connect($this->host, $this->usuario, $this->password);
          $con = mysql_select_db($this->dbname);
          if ($link && $con) { echo 'in server'; }
     }
     
     
     function offServer()
     {
          $unlink = mysql_close($link);
          if ($unlink) { echo 'out server'; }
     }

}

$var = new Connect();
$var->onServer();
  echo 'run your queries here';
$var->offServer();
?>

Initial URL

                                

Initial Description

                                

Initial Title
Simple Class Connection

Initial Tags
mysql, php, server

Initial Language
PHP