FreeHostia Forums
https://forum.freehostia.com/

MySQL connection refused
https://forum.freehostia.com/viewtopic.php?f=7&t=65697
Page 1 of 1

Author:  edouard [ Fri Jun 26, 2015 6:33 pm ]
Post subject:  MySQL connection refused

I have a script that connects to MySQL database, executes a query and sends the result as json data as a response. However I keep getting "Connection refused" as a response when using the following PHP method in the script:

$conn = mysqli_connect( "mydomainname.com", "myusername", "mypassword", "mydatabasename" );

I tested everything locally with EasyPHP DevServer and now that it's ready for production I inserted all records on the database at freehostia and moved the script to my domain at freehostia, but it doesn't work...

I tried the IP address as the host parameter for mysqli_connect but nothing is returned, not even a "echo" method works with that... What am I doing wrong, isn't the host my domain name ? I know that the username and database name are the same and correct, and I am sure that the password is correct, so that only leaves the host parameter as wrong only if I should not use my domain name...

Any help would be welcome

Thanks

Author:  Victor [ Sat Jun 27, 2015 5:03 am ]
Post subject:  Re: MySQL connection refused

Please note that you should use localhost for the name of the host that your PHP script connects to. Further, the database name and the database username are the same, so the function will look like this:

$conn = mysqli_connect( "localhost", "mydatabasename", "mypassword", "mydatabasename" );

Author:  edouard [ Wed Jul 01, 2015 11:47 am ]
Post subject:  Re: MySQL connection refused

Ok, localhost worked.. Thank you

Author:  Victor [ Fri Jul 03, 2015 4:53 am ]
Post subject:  Re: MySQL connection refused

You are welcome!

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/