I have used the follwoing code to query my database in server but i’m getting this error : Connection failed: No connection could be made because the target machine actively refused it.
<?php
$servername = "databases.000webhost.com";
$username = "id*****_####";
$password = "$%^&*%$#";
$dbname = "id*****_####";;
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT * FROM TableName";
$result = mysqli_query($conn, $sql);
$rows = array();
while($r = mysqli_fetch_assoc($result)) {
$rows[] = $r;
}
echo json_encode($rows, 128);
mysqli_close($conn);
?>
akhilkumar332:
localhost
Connection failed: Access denied for user ‘id*****_####’@‘localhost’ (using password: YES)
Can you try this:-
$conn=mysqli_connect("localhost","dbuser","dbpassword","dbname")or die("Connection to Database Server Failed");
akhilkumar332:
$conn=mysqli_connect(“localhost”,“dbuser”,“dbpassword”,“dbname”)or die(“Connection to Database Server Failed”);
Connection to Database Server Failed
I have a free account is that a issue
No that’s not an issue.
Can you delete the database and try again??
okay i will rebuild the database
done didn’t help
still Connection to Database Server Failed
Can you post the username and password you are using please?
User_Name : id944850_nsnikhil
Password : xxxx
Working fine this end.
Check your code and make sure you’ve select the most correct version of PHP that agrees with your code.
host: localhost
user: id944850_nsnikhil
database: id944850_gymchart
password: whatever you used.