Reputation: 278
I have a website on IIS and want to access a database on a remote host.
my code:
$this->db = new mysqli($hostname, $username, $password, $dbname);
I get this error:
Es konnte keine Verbindung hergestellt werden, da der Zielcomputer die Verbindung verweigerte
In english its like
Remote Host refused connection
Default Port is 3306, when I execute
$this->db = new mysqli($hostname, $username, $password, $dbname, 3306);
I get the same result.
Via cmd telnet I can't connect to $hostname 3306, but to $hostname 1433.
So I tried
$this->db = new mysqli($hostname, $username, $password, $dbname, 1433);
But this isn't working either. I get
mysqli::__construct(): MySQL server has gone away
mysqli::__construct(): Error while reading greeting packet. PID=3276
Do you know how I can get the connection to the database?
Upvotes: 0
Views: 825
Reputation: 3932
Based on the info in your question, it looks like the remote database is SQL Server, not MySQL. Therefore you need to use PHP's MSSQL library: http://php.net/manual/en/book.mssql.php
It usually requires additional installation/configuration though.
Upvotes: 3