2
$host="mysql13.000webhost.com";      
$username="a1346032"; 
$password="<password>"; 
$db_name="a1346032_newdb"; 
$tbl_name="members"; 

mysqli_connect("$host", "$username", "$password")or die("cannot connect"); 
mysqli_select_db("$db_name")or die("cannot select DB");

I have made my mysqli database in free hosting site 000webhost now i want to connect my database to my php code but every time i am getting error that "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. in C:\wamp\www\hh1\checklogin.php on line 11" please help me on this and suggest if i have to add up something? thanks.

S.S
  • 59
  • 1
  • 2
  • 7
  • when you start localhost/phpmyadmin. than which username and password are use – Mayank Vadiya Jan 05 '16 at 11:20
  • most likely that remote DB service is not accessible through the firewall. Try a telnet connection to your DB on port 3306 – Jan Jan 05 '16 at 11:20
  • As above, probably remote connections are not allowed with that (free, eg unreliable) host. If you are working locally (WAMP) just use your local mysql – Steve Jan 05 '16 at 11:23
  • `000webhost.com` douse not support remote mysql connection, you have to install and use your local mysql server, or upload your php code to `000webhost` server – Armen Jan 05 '16 at 11:24

2 Answers2

10

000webhost only lets you access the database through it's own PHP host or it's own PHPMyAdmin.

You can't access it from your own computer or another server, unless you upgrade your account (by paying).

enter image description here

Phiter
  • 14,570
  • 14
  • 50
  • 84
0

Use this at that place

$host="localhost"; $username="a1346032"; $password="<password>"; $db_name="a1346032_newdb"; $tbl_name="members"; $con=mysqli_connect("$host", "$username", "$password", $db_name)or die("cannot connect"); mysqli_select_db``($con, "$db_name")or die("cannot select DB");

Raviteja V
  • 344
  • 2
  • 7