1

I downloaded an Event management software and install wamp server. Everything is fine but when I try to sign up into the website, it is showing me this

( ! ) Warning: mysqli_connect(): (HY000/1049): Unknown database 'eventmanagmnt' in C:\wamp64\www\Emsp\connection.php on line 2

Call Stack
#   Time    Memory  Function    Location
1   0.0507  403176  {main}( )   ...\Login.php:0
2   0.1265  404264  include( 'C:\wamp64\www\Emsp\connection.php' )  ...\Login.php:2
3   0.1266  404264  mysqli_connect ( )  ...\connection.php:2
1
  • 2
    step one: make 100% sure the database you are trying to access exists. because, obviously, it doesn't. Apr 27, 2019 at 7:33

6 Answers 6

12

New versions of WAMP seems to install both MySQL and MariaDB. And when I logged in through the phpMyAdmin, I saw that the MySQL is using the port 3308.

enter image description here


So in my PHP code, instead of using just localhost for my database hostname, I added the port to it like this: localhost:3308 and it worked.

$db = new mysqli('localhost:3308', 'root', 'password', 'db_name');
4

How can I solve this “Warning: mysqli_connect(): (HY000/1049): Unknown database” problem?

If you are very sure you have created the database, then go to your connect file and add the port (3308) to your host variable [private $host = "localhost:3308";]. It's worked for me.

1

In your connection.php line 2 verify your credentials if they're correct for your localhost.

mysqli_connect("localhost","your_username","your_password","your_database_name");

When we download such a project we first have to check the connection for the database. If you could provide me with your php version and a snippet from your connection.php file.

0

For me this worked:

If you are using wamp 3.1.9 the problem is you created the database using MariaDB. Try to create or import the database using Mysql selection as the server choice it will connect.

0

For passing localhost--> use "localhost:3308" instead of just localhost or 127.0.0.1

see this code- $con = new mysqli("localhost:3308","root","","database_name");

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Nov 23, 2021 at 12:23
0

The solution is using

$db = mysqli_connect('localhost', 'root', '', 'turbo_logistics','3308'); 

or

$db = new mysqli('localhost:3308', 'root', 'password', 'db_name');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.