2013-10-12 4 views
0

이전 웹 사이트를 이전 시스템에서 새 사이트로 옮겼습니다. 이제 데이터베이스 연결에 문제가 있습니다. 버전은 Mysql 5.1.67 및 phpMyadmin 3.4.3.2입니다. 문제가 어디에 있습니까?데이터베이스 서버에 연결할 수 없습니다.

경고 : mysqli :: mysqli() [mysqli.mysqli] : (/ 2002 HY000가) : 웹 사이트에서

소켓을 통해 로컬 MySQL 서버에 연결할 수 없습니다 '은/var/lib 디렉토리/mysql을 라인 13 에 /home/do031500/www_root/lib/database.inc.php에서 /mysql.sock '(2) 데이터베이스 서버에 연결할 수 없습니다

database.inc.php :

class CDatabase { 

public $Connected = false; 
private $Mysqli; 
public $Result; 

// Connect to database server 
function Connect() { 
    global $DatabaseSupport; 
    if ($DatabaseSupport) { 
    $this->Mysqli = new mysqli(dbServer, dbUser, dbPassword, dbDatabase); 
    if (mysqli_connect_errno()) { 
     $this->Connected = false; 
     Terminate("Could not connect to database server"); 
     } else { 
     $this->Connected = true; 
     $this->Mysqli->autocommit(FALSE); 
     $this->Mysqli->set_charset("utf8"); 
    } 
    } 
} 

// Disconnect from server 
function Disconnect() { 
    if ($this->Connected) { 
     $this->Mysqli->close(); 
    } 
} 

// Execute query 
function Query($Query) { 
    $this->Result = false; 
    if ($this->Connected) { 
      $this->Result = $this->Mysqli->query($Query, MYSQLI_STORE_RESULT); 
     if (!$this->Result) 
     Terminate('Invalid query: '.$this->Mysqli->error); 
     } 
    return $this->Result; 
} 

// Close query query 
function Close($Datalink) { 
    if ($this->Connected) { 
    mysqli_free_result($Datalink); 
     } 
} 

// Commit 
function Commit() { 
    if ($this->Connected) 
    $this->Mysqli->Commit(); 
} 

// Rollback 
function Rollback() { 
    if ($this->Connected) 
    $this->Mysqli->Rollback(); 
} 

// GetRecordCount 
function RecordCount($DataLink) { 
    if ($this->Connected) 
      return $DataLink->num_rows; 
    else 
    return 0; 
} 

// Get last RecordID 
function GetLastRecordID() { 
    if ($this->Connected) 
      return $this->Mysqli->insert_id; 
    else 
    return false; 
} 

// Get next line from query 
function GetNextLine($Datalink = NULL) { 
    if ($this->Connected) { 
      if ($Datalink != NULL) 
      $this->Result = $Datalink; 
     return $this->Result->fetch_array(MYSQL_ASSOC); 
     } 
} 

// Execute query and return first line 
function QueryFirstLine($Query) { 
    if ($this->Connected) { 
      if ($this->Result = $this->Query($Query)) 
      return $this->Result->fetch_array(MYSQL_ASSOC); 
     } 
} 

// GetField list for current query 
function GetFieldList($Datalink = NULL) { 
    if ($this->Connected) { 
      if ($Datalink != NULL) 
      $this->Result = $Datalink; 
      //$FieldsCount = $this->Result->field_count; 
    $List = NULL; 
    while ($Finfo = $this->Result->fetch_field()) { 
      $List[] = $Finfo->name; 
    } 
     return $List; 
     } 
} 

// encode value 
function EncodeValue($Value) { 
    return $Value; 
} 

// move item 
function MoveItem($SQL, $RecordID, $Forward, $TableName) { 
    $Query = $this->Query($SQL); 
    while ($Line = $this->GetNextLine($Query)) { 
      $List[] .= $Line['RecordID']; 
    } 
    $HasMove = false; 
    for ($i = 0; $i < count($List); $i++) { 
    if ((!$HasMove) && ($List[$i] == $RecordID)) { 
     if ($Forward) { 
     if ($i < count($List)-1) { 
      $a = $List[$i+1]; 
      $List[$i+1] = $List[$i]; 
      $List[$i] = $a; 
      $i++; 
     } 
     } else { 
     if ($i > 0) { 
      $a = $List[$i-1]; 
      $List[$i-1] = $List[$i]; 
      $List[$i] = $a; 
     } 
     } 
     $HasMove = true; 
    } 

    } 

    $cnt = 1; 
     foreach ($List as $Key=>$Value) { 
     $this->Query("update $TableName set OrderNo='".$cnt."' where RecordID='$Value'"); 
    $cnt++; 
    } 
     $this->Commit(); 
} 


} 
+0

dbServer는 유효한 PHP 변수가 아닙니다. '$'를 사용하십시오 – cgTag

+0

이봐, 문제 없어. 문제는 dbserver, username, password의 주소를 가진 문서에서 DB 서버에 대한 업데이트 정보를 가지고 있다는 것이 었습니다. 이제 작동 중입니다. – patrik87

답변

0

Initi 귀하의 연결 변수 중 하나 때문일 것입니다. 새 서버의 정보가 모두 있음을 다시 확인 했습니까? 서버, 포트, 사용자 이름, 암호, 데이터베이스, 테이블?

+0

서버 주소, 사용자 이름, 데이터베이스 및 테이블이 있는데 어딘가에 업데이트가 필요합니까? 아니면 자동으로? (이전 DB와 새로운 DB 사이의 다른 암호) – patrik87

+0

예 ... 서버간에 mysql 서버의 암호가 다른 경우이를 업데이트해야합니다. 나는 당신이 당신의 프로그램 (dbServer, dbUser, dbPassword, dbDatabase)에서 이러한 변수들을 설정하고 있는지 알지 못하지만 새로운 서버에서 설정이 다른 경우 변경해야 할 것입니다. 덕분에 – kevindeleon

+0

. 나는이 웹 사이트를하지 않았다, sooo는 어려울 것이다. – patrik87

관련 문제