Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

php - How can i solve this "Warning: mysqli_connect(): (HY000/1049): Unknown database" problem?

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:wamp64wwwEmspconnection.php on line 2

Call Stack
#   Time    Memory  Function    Location
1   0.0507  403176  {main}( )   ...Login.php:0
2   0.1265  404264  include( 'C:wamp64wwwEmspconnection.php' )  ...Login.php:2
3   0.1266  404264  mysqli_connect ( )  ...connection.php:2
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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');

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...