What do I need to change to alter login info?

Installation and configuration iussues

Moderators: macek, egami, gesf

KyleS
New php-forum User
New php-forum User
Posts: 1
Joined: Sun May 29, 2011 9:07 am

What do I need to change to alter login info?

Postby KyleS » Sun May 29, 2011 9:11 am

I have to migrate a website that has a database and I cant get it to login the database structure is completely different. Can you guys tell me what I need to change to make the website recognize a new database? Here is the code I really appreciate the help

Code: Select all


<?php
/*
 * Created on Oct 17, 2008
 *
 * Matthew N. Cobb
 */
 
if(!isset($g_link)) {
    $g_link = false;
}

Class Database {
   var $PARAMETERS;
   var $ParametersCurrent;

   function __construct($Parameters) {
      $this->PARAMETERS = $Parameters;
   }
   
   function query($sql, $Parameters = null) {e-nocooki
      mysql_query($sql, $this->getComysql_connectnnection($Parameters));
   }
   
   function querySelect($sql, $Parameters = null) {
      return mysql_query($sql, $this->getConnection($Parameters));
   }
   
   function queryInsert($sql, $Parameters = null) {
      $connection = $this->getConnection($Parameters);
      if(!mysql_query($sql, $connection)) die(mysql_error());
      
      return mysql_insert_id($connection);
   }

   function queryUpdate($sql, $Parameters = null) {
      mysql_query($sql, $this->getConnection($Parameters));
   }
   
   function queryDelete($sql, $Parameters = null) {
      if(!mysql_query($sql, $this->getConnection($Parameters))) die(mysql_error());
   }
   
   function getConnection($Parameters = null) {
      global $g_link;

      if(!is_array($Parameters)) $Parameters = $this->PARAMETERS;
      
      if(!$g_link || (($this->ParametersCurrent['schema'] != $Parameters['schema']) && (($this->ParametersCurrent['host'] != $Parameters['host']) || ($this->ParametersCurrent['username'] != $Parameters['username']) || ($this->ParametersCurrent['password'] != $Parameters['password'])))) {
         $this->openConnection($Parameters);
        }
      else if($this->ParametersCurrent['schema'] != $Parameters['schema']) {
           mysql_select_db($Parameters['schema'], $g_link) or die('Could not select database.');
           $this->ParametersCurrent['schema'] = $Parameters['schema'];
        }
      
      return $g_link;
   }
   
   function openConnection($Parameters) {
      global $g_link;
       
       $g_link = mysql_connect($Parameters['host'], $Parameters['username'], $Parameters['password']) or die('Could not connect to database server.');
       mysql_select_db($Parameters['schema'], $g_link) or die('Could not select database.');
        $this->ParametersCurrent = $Parameters;
    }
   
   function closeConnection() {
      global $g_link;
       
        if($g_link != false) mysql_close($g_link);
       
        $g_link = false;
   }
   
   function __destruct() {
      $this->closeConnection();   
    }
}
?>



johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: What do I need to change to alter login info?

Postby johnj » Mon May 30, 2011 6:44 am

Take a look at the function openConnection. In that, there is a host, username , password and a database name. Display these four parameters and see if these parameters are valid for the new server.


Return to “MySQL Installation”

Who is online

Users browsing this forum: No registered users and 0 guests

cron