Reputation: 15
I am getting familiar with WAMP and struggling with very basics. I created a test website and test database, trying to connect db to the site.
Yet I get constantly error instead of connection, error code not telling what's it all about even if site PHP settings are set to "display errors = yes". I have checked creditials dozen of times, they are correct.
Below is the simple code I made, could you please help me out what's wrong with it? Creditials are from sites mySQL manager, changed so that I can't be indentified but in similar shape.
Should the host be something else than a string? Is the PHP script somehow obsoleted/wrong or does this has something do with the fact that I am playing with free and slow web server host?
My code:
<DOCTYPE! html>
<html>
<body>
<h1>Working title</h1>
<?php
$host = "sql123.epizy.com";
$username = "epiz_12345678";
$password = "nottherealpassword";
$dbname = "epiz_12345678_NameofDatabase";
$link = mysqli_connect($host, $username, $password, $dbname);
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
mysqli_close($link);
?>
</body>
</html>
Thank you for your help!
Upvotes: 1
Views: 82
Reputation: 983
Looking at their support page, it does say:
"Make sure you are connecting from within hosting account.
InfinityFree databases are only accessible from within your InfinityFree hosting acounts. Our database servers are not accessible from other locations, like developer tools on your own computer, websites on other hosting providers, game software, mobile apps and so on. Remote database access is only available with premium hosting."
See here: https://support.infinityfree.net/mysql/common-mysql-errors/
Upvotes: 0
Reputation: 90
WAMP is a localhost tool. here you have $host = "sql123.epizy.com";
as database host.
Solution1:
Creating an api [where you can send queries there] in epizy.com webhost to communicate between your server and the database server.
Solution2:
Simply use your own database on WAMP server.
Upvotes: 1