SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2008
    Location
    Plymouth, United Kingdon
    Posts
    449
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Warning: mysqli::mysqli(): (HY000/2005): Unknown MySQL serve

    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 Code:
    <?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\n"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

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,189
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Both pages work fine for me, i see the same content for both of them

  3. #3
    SitePoint Evangelist
    Join Date
    Dec 2008
    Location
    Plymouth, United Kingdon
    Posts
    449
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SgtLegend View Post
    Both pages work fine for me, i see the same content for both of them
    if you check this page on and off u will see the error message, for instance, it is not working now,

    http://coexistencetrustnews.org/


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •