Hi,
This is very strange and doing my head in. I simply cannot understand why with the same content, the same scripts, and at the same server, it works on site but not the other, below is the error message,
http://nano-visions.net/dump/ - it works!
http://coexistencetrustnews.org/ - it doesn’t!
Warning: mysqli::mysqli(): (HY000/2005): Unknown MySQL server host ‘coexistencetrustnews.org.mysql’ (2) in /customers/coexistencetrustnews.org/coexistencetrustnews.org/httpd.www/models/class_database.php on line 11 Connect failed: Unknown MySQL server host ‘coexistencetrustnews.org.mysql’ (2) Warning: mysqli::close(): Couldn’t fetch mysqli in /customers/coexistencetrustnews.org/coexistencetrustnews.org/httpd.www/models/class_database.php on line 160
any idea?
below is my database class which I cannot find any error…
<?php
#connects the database and handling the result
class __database {
protected $connection = null;
protected $error = null;
#make a connection
public function __construct($hostname,$username,$password,$database)
{
$this -> connection = new mysqli($hostname,$username,$password,$database);
if (mysqli_connect_errno())
{
printf("Connect failed: %s\
", mysqli_connect_error());
exit();
}
}
#fetches all result rows as an associative array, a numeric array, or both
public function fetch_all($query)
{
$result = $this -> connection -> query($query);
if($result)
{
while($row = $result -> fetch_assoc())
{
$return_this[] = $row;
}
if (isset($return_this))
{
return $return_this;
}
else
{
return false;
}
}
else
{
$this -> error = $this -> connection -> error;
return false;
}
}
#fetches a result row as an associative array, a numeric array, or both
public function fetch_assoc_while($query)
{
$result = $this -> connection -> query($query);
if($result)
{
while($row = $result -> fetch_assoc())
{
$return_this[] = $row;
}
if (isset($return_this))
{
return $return_this;
}
else
{
return false;
}
}
else
{
$this -> error = $this -> connection -> error;
return false;
}
}
#fetch a result row as an associative array
public function fetch_assoc($query)
{
$result = $this -> connection -> query($query);
if($result)
{
return $result -> fetch_assoc();
}
else
{
$this -> error = $this -> connection -> error;
return false;
}
}
#get a result row as an enumerated array
public function fetch_row($query)
{
$result = $this -> connection -> query($query);
if($result)
{
return $result -> fetch_row();
}
else
{
$this -> error = $this -> connection -> error;
return false;
}
}
#get the number of rows in a result
public function num_rows($query)
{
$result = $this -> connection -> query($query);
if($result)
{
return $result -> num_rows;
}
else
{
$this -> error = $this -> connection -> error;
return false;
}
}
#performs a query on the database
public function query($query)
{
$result = $this -> connection -> query($query);
if($result)
{
return $result;
}
else
{
$this -> error = $this -> connection -> error;
return false;
}
}
#escapes special characters in a string for use in a SQL statement, taking into account the current charset of the connection
public function real_escape_string($string)
{
$result = $this -> connection -> real_escape_string($string);
if($result)
{
return $result;
}
else
{
$this -> error = $this -> connection -> error;
return false;
}
}
#display error
public function get_error()
{
return $this -> error;
}
#closes the database connection when object is destroyed.
public function __destruct()
{
$this -> connection -> close();
}
}
?>
many thanks,
Lau