[英]Cannot connect to mysql database [phpmyadmin]
in my php code Im connecting to MySQL with this code: 在我的PHP代码我使用此代码连接到MySQL:
if ($_SERVER["SERVER_ADDR"]=="localhost") { define("SQL_HOST","localhost"); define("SQL_DBNAME","dungeons"); define("SQL_USERNAME",xxx); define("SQL_PASSWORD",xxx); } else { define("SQL_HOST","127.0.0.1"); define("SQL_DBNAME","dungeons"); define("SQL_USERNAME", xxx); define("SQL_PASSWORD",xxx); } mysql_connect(SQL_HOST, SQL_USERNAME, SQL_PASSWORD) or die("Cannot connect to mySQL: " . mysql_error()); mysql_select_db(SQL_DBNAME) or die("Cannot connect to the database: ". mysql_error());
The error message says 错误消息说
Unknown database 'dungeons', when selecting db. 选择db时,未知数据库'dungeons'。
I don't have any idea where the problem is, since the database is made and I have successfully connected to the mysql with the code. 我不知道问题出在哪里,因为数据库已经建成并且我已经使用代码成功连接到mysql。
The error is correctly saying that the database is not available or not there. 错误正确地说数据库不可用或不存在。 First create a new database in phpmyadmin and name it dungeons. 首先在phpmyadmin中创建一个新数据库并将其命名为dungeons。 After that try your script. 之后尝试你的脚本。 Thank you 谢谢
The error message says 错误消息说
Unknown database 'dungeons' 未知的数据库'地下城'
There doesn't exist a database with name "dungeons". 没有名为“dungeons”的数据库。
First create a database using 首先使用创建数据库
create database dungeons;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.