It is currently Tue Sep 26, 2017 9:20 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: MySQL connection refused
PostPosted: Fri Jun 26, 2015 6:33 pm 
Newbie
Newbie

Joined: Fri Jun 26, 2015 6:18 pm
Posts: 2
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


Top
 Profile  
 
 Post subject: Re: MySQL connection refused
PostPosted: Sat Jun 27, 2015 5:03 am 
Newbie
Newbie

Joined: Wed Nov 19, 2014 6:54 am
Posts: 10
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" );


Top
 Profile  
 
 Post subject: Re: MySQL connection refused
PostPosted: Wed Jul 01, 2015 11:47 am 
Newbie
Newbie

Joined: Fri Jun 26, 2015 6:18 pm
Posts: 2
Ok, localhost worked.. Thank you


Top
 Profile  
 
 Post subject: Re: MySQL connection refused
PostPosted: Fri Jul 03, 2015 4:53 am 
Newbie
Newbie

Joined: Wed Nov 19, 2014 6:54 am
Posts: 10
You are welcome!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ]  Moderators: Moderators, Support Team

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Hosting | Domains | Servers | Extras | Order | Support | Contacts | FreeHostia © 2011