0

Hi i am trying to access remote database using PHP. remote database is MySQL. Below is the screen shot of the error i am getting.can any one help me.Thanks in advance.

following are perfectly alright i have checked:-

  1. Database name
  2. port number
  3. IP address
  4. username and password

here is the database connectivity code

<?php

class Database {
/*  
    public  $dbhost = "mysql:dbname=a_t;host=localhost:3306";
    $dbhost = "mysql:host=10.75.225.171;port=3306;dbname=apt";
    public  $dbuser = "root";
    public  $dbpass = "root";
    public  $dbname = "a_t";
    public  $connection;
    public  $selectdb;
    public  $isConnected;
    public  $dbh;

    */

    public  $dbhost = "mysql:dbname=25thcraft;host=52.xx.xx.xxx;port=3306";

    public  $dbuser = "tribhuvan";
    public  $dbpass = "123456";
    public  $dbname = "25thcraft";
    public  $connection;
    public  $selectdb;
    public  $isConnected;
    public  $dbh;

    //$user = 'dbuser';
    //$password = 'dbpass';

    public function Connection()
    {
        try
        {   
             $this->dbh = new PDO($this->dbhost, $this->dbuser, $this->dbpass);
            // echo "true";
                return  $this->dbh;
        }
        catch(Exception $e)
        { 
                $this->isConnected = false;
                throw new Exception($e->getMessage());
        }
    }

    public function Disconnect()
    {
        $this->datab = null;
        $this->isConnected = false;
    }
}
?>

enter image description here

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
3bu1
  • 977
  • 12
  • 30
  • You might find that the webhost has the database firewalled in such a way as to only accept connections from a particular host ( this is very common ) and not from any remote host such as your PC at home. You could create a proxy on your live site to which you connect perhaps – Professor Abronsius Jan 11 '16 at 14:04

1 Answers1

0

If you want make a connection to a remote connection, the host must be configured to accept these connections. Which are disables by default. The best you can contact the host to look into this.

Perrykipkerrie
  • 380
  • 1
  • 3
  • 12