0

Warning: mysqli_connect(): (HY000/1049): Unknown database 'art_gallery'

The database art_gallery is correctly imported and username is root, password is ``

<?php
$link=mysqli_connect("localhost","root","","art_gallery");
if(mysqli_connect_error())
{
    echo "Connection error".mysqli_connect_error();
    exit;
}
Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Check this post [https://stackoverflow.com/questions/45979819/warning-mysqli-connect-hy000-1049-unknown-database-in-mac-terminal-only](https://stackoverflow.com/questions/45979819/warning-mysqli-connect-hy000-1049-unknown-database-in-mac-terminal-only) – Imam San Jul 03 '20 at 19:25
  • Please read: [Should we ever check for mysqli_connect() errors manually?](https://stackoverflow.com/q/58808332/1839439) – Dharman Jul 03 '20 at 20:01
  • use phpmyadminj to check the database, especially the spelling. – nbk Jul 03 '20 at 22:02

2 Answers2

0

Normally in this type of error there are two possibilities.

First is that there are some Spelling errors. or Secondly you have different servers installed on your machine.

Mostly it would be due to second cause, thus to identify those servers uniquely, you have to specify the port number in the localhost when connecting via mysql connect statement

Try mysqli_connect(“localhost:3308”,″root”,””,”dbname”) (default is 3306) it can be changed.

The port number can be checked in the phpmyadmin at top center of panel as something like server:3308

-2

I think you can use new mysqli() function instead of mysqli_connect() function. Hope I could help you.

MBiabanpour
  • 370
  • 1
  • 13
  • There's not really any difference, `mysqli_connect` just returns a new `mysqli` object. – Rogue Jul 03 '20 at 21:21