dssjxvbv918586 2016-05-26 13:54
浏览 263

无法使用mysqli_select_db选择数据库

<?php // sqltest.php
$db_hostname='localhost';
$db_database='book';
$db_username='';
$db_password='';

$db_server = mysqli_connect($db_hostname, $db_username, $db_password);
if (!$db_server) die("Unable to connect to MySQL: " . mysqli_error());
mysqli_select_db($db_server,$db_database )
or die("Unable to select database: " . mysqli_error($db_server));

I am using localhost:8080 and localhost:8080/phpMyAdmin to access the whole thing. Now I have code which runs like you see above and getting error message unable to select database. What should I do to remove the error.

  • 写回答

1条回答 默认 最新

  • dongzhi9032 2016-05-26 13:56
    关注

    You don't do mysql_select_db. You do this way:

    $db_server = mysqli_connect($db_hostname, $db_username, $db_password, $db_database);
    

    See the manual:

    Note: This function should only be used to change the default database for the connection. You can select the default database with 4th parameter in mysqli_connect().

    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型