Mysql php error - php

I am trying to connect from my PC to a database that is hosted by knowhost.
$con = new mysqli('188.214.58.120','user','pass','db');
When i compile this it shows me this: mysqli::__construct(): (HY000/2002): No connection could be made because the target machine actively refused it.
Where is the problem?

Related

Connecting to a remote Phymyadmin Mysql server from a local php server

I'm hosting a php server on localhost using command line on Windows, and I'm trying to establish a connection between it and a Mysql database hosted on my school's servers.
I try to make the connection like so:
$db = mysqli_connect('host', 'username', 'password', 'db_name');
which results in this error:
Warning: mysqli_connect(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
What might be the cause of this error?

Unable to connect to SQL server using mysqli_connect, but MSSMS connects fine

I've read many questions similar to this but none of the answers have been relevant to me. I'm trying to access a SQL server using PHP. Both the SQL server and PHP are running on my Windows 10 machine. Here is my PHP code (the username and password are arbitrary):
$connection = mysqli_connect('127.0.0.1', 'hmuuser', 'password');
This causes the following error:
PHP Warning: mysqli_connect(): (HY000/2002): No connection could be made because the target machine actively refused it.
Here is my connection using MSSMS (which is successful):
EDIT:
I was able to solve my problem using this link: http://blog.citrix24.com/configure-sql-express-to-accept-remote-connections/
Using this link I enable SQL Browser, and set a static port to connect to SQL server with. However, I'm presented with a new error:
PHP Warning: mysqli_connect(): MySQL server has gone away in C:\HMUAPI\Index.php on line 7
PHP Warning: mysqli_connect(): Error while reading greeting packet. PID=9920 in C:\HMUAPI\Index.php on line 7
PHP Warning: mysqli_connect(): (HY000/2006): MySQL server has gone away in C:\HMUAPI\Index.php on line 7
My code has been changed to the following to cause this error: $connection = mysqli_connect('127.0.0.1:1434', 'hmuuser', 'password');
Add a database name
$connection = mysqli_connect('127.0.0.1', 'hmuuser', 'password','dbname');
Also here is suggest - Actively refused it" means that the host sent a reset instead of an ack when you tried to connect. It is therefore not a problem in your code. Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that port. This may be because it is not running at all or because it is listening on a different port.
I guess the problem is, that you use MySQLi to connect to a MSSQL server.
You should use the correct MSSQL extension instead.
Microsoft published their SQL-Server for PHP driver on GitHub: https://github.com/Microsoft/msphpsql
Or you use the older extension which is documented in the PHP manual: http://de2.php.net/manual/en/book.mssql.php
And at least you can set up ODBC.
One of them should resolve your problem.

SQL database with windows authentication

I have installed my sql database with windows authentication, but now don't know how to connect to it.
The message I am getting is
Error
php_network_getaddresses: getaddrinfo failed: No such host is known.
/the database is on my local PC and I copied the path to it which is
"C:\Users\MyName\Documents\My Web Sites\For evaluation-3col\App_Data\test.sdf"
so the command line is
$dbc = mysqli_connect("C:\Users\MyName\Documents\My Web Sites\For evaluation-3col\App_Data\test.sdf")
or die(mysqli_connect_error())
I am a very new person to this and would really appreciate help.
Thanks

socket connection between c server and PHP client

I trying to establish a socket communication from PHP client to C target, But I am always getting warning error as below:
Warning: socket_connect(): unable to connect [10061]: No connection could be made because the target machine actively refused it.
Note:
I am already tried the links:
http://www.pmoghadam.com/homepage/HTML/c-php-unix-domain-socket.html
socket_connect(): unable to connect [10061] - target machine actively refused it

Local php-mysql install not connecting to remote db?

I'm trying to connect to a remote database from my local machine, and php is throwing a nice vague error, so I was hoping someone with a bit more experience in this area could point me in the right direction. The error I'm getting:
Warning: mysql_connect() [function.mysql-connect]: Connection refused in /my/obfuscated/directory/config.php on line 10
Could not connect: Connection refused
Your error is "Connection refused". So, remote sever refuse your request.
Try to configure remote server to allow your connection

Categories