Can't select database [PHP/SQL]

Connect with other users about what to run on your webhosting (and how to run it) here.
Post Reply
HappyMaskGuy
New to forums
New to forums
Posts: 3
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Sat May 30, 2020 5:15 am

Can't select database [PHP/SQL]

Post by HappyMaskGuy »

Code: Select all

<?php
include(path)
$link=mysqli_connect($host,$username,$password);

@mysqli_select_db($database, $link) or die( "Unable to select database");
If I use Echo it reads the host, username, password and the word "stats" so the path is definitely correct.

Code: Select all

<?php
$host="(host)";
$username="(username)";
$password="(password)";
$database="stats";
?> 
I created the "stats" database in the website setting control panel. I used PHPMyAdmin to fill in a few test details.

Any idea why I keep getting the "unable to select database"? Feel like I'm forgetting something very basic.
User avatar
hiimcody1
Staff
Staff
Posts: 1593
Joined: Wed Dec 28, 2011 4:59 pm

Re: Can't select database [PHP/SQL]

Post by hiimcody1 »

You'd need to make sure to use the entire name of the database as it is displayed on your Databases tab.

The database would be something like this if you named it "stats":

"username_stats"
HappyMaskGuy
New to forums
New to forums
Posts: 3
Joined: Sat May 30, 2020 5:15 am

Re: Can't select database [PHP/SQL]

Post by HappyMaskGuy »

I have done that, just didn't want to post username here
User avatar
hiimcody1
Staff
Staff
Posts: 1593
Joined: Wed Dec 28, 2011 4:59 pm

Re: Can't select database [PHP/SQL]

Post by hiimcody1 »

Do you already have a support request open with us by chance? If so, please bump it, otherwise go ahead and open one referencing this forum post so we can take a closer look and verify that there isn't a problem with the database server.
Post Reply