php 我收到数据库未知的错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22915257/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:21:42  来源:igfitidea点击:

I am getting the error that database is unknown

phpmysqlxampp

提问by Gintare Statkute

Where is mistake? I try to connect to database from php script. I am getting the error that database is unknown. Database for sure exists, i can see this from PhpMyAdmin. I use XAMPP v3.2.1 with mysqlnd 5.0.11-dev and php v5.5.9.

错在哪里?我尝试从 php 脚本连接到数据库。我收到数据库未知的错误。数据库肯定存在,我可以从 PhpMyAdmin 看到这个。我将 XAMPP v3.2.1 与 mysqlnd 5.0.11-dev 和 php v5.5.9 一起使用。

Script file debug1.php in folder c:\xampp\htdocs:

文件夹 c:\xampp\htdocs 中的脚本文件 debug1.php:

$conn=mysqli_connect( 'localhost', 'root', '', $vdbname ) or die( "cannot connect to server".mysqli_error() ); 

When i run this file from browser windows using url: "localhost/debug1.php" i am getting error message:

当我使用 url: "localhost/debug1.php" 从浏览器窗口运行此文件时,我收到错误消息:

Warning: mysqli_connect(): (HY000/1049): Unknown database 'gintare_calendar' in C:\xampp\htdocs\debug1DBconn.php on line 5

回答by brkz

You may want to look for whitespace in database name. From phpMyAdmin go to database Operation sections and see if white space has been added in front or after database name.

您可能希望在数据库名称中查找空格。从 phpMyAdmin 转到数据库操作部分,查看是否在数据库名称之前或之后添加了空格。

回答by Cagy79

This means the database you want to connect to is not called "gintare_calendar".

这意味着您要连接的数据库不称为“gintare_calendar”。

Open your MySQL administration package (phpmyadmin) and verify the actual nameof the database you want to connect to.

打开您的 MySQL 管理包 (phpmyadmin) 并验证您要连接的数据库的实际名称

回答by Gintare Statkute

I am sorry, i forget that i reinstalled XAMPP. It is true. There is no database. I have to create the database, import previous tables and than everything works again.

对不起,我忘了我重新安装了 XAMPP。是真的。没有数据库。我必须创建数据库,导入以前的表,然后一切正常。