Cant seem to connect to my database

So i am trying to have a php script connect to the database thats set up through Infinity Free.

The php script is simple and looks like this:



$db_name = "database_name";

$mysql_user = "username";

$mysql_pass = "userpass";

$server_name = "server_domain";

$con = mysqli_connect($db_name, $mysql_user, $mysql_pass, $server_name);


echo '{"message":"Unable to connect to the database."}';


echo "Connected";


But this just doesnt even connect to the database. and the info of username database name and such are all correct.

I am unsure what is wrong. or whether i just dont have access to my database or something else entirely.

I am new to the scene and but i am willing to learn. Any help is appreciated

The mysqli_connect function should be like this syntax:

$con = mysqli_connect($server_name, $mysql_user, $mysql_pass, $db_name);

and not whatever there is on your code. Also, the MySQL database host can be found on the “MySQL Databases” section of the Control Panel.


Thank you and i understand i can check my database through the phpMyAdmin link in my dashboard.

but what i mean is that i have an app trying to send and receive data using the php scripts i put in my htdocs. i guess i just need to go over my php scripts to make sure they are set up right

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.