这是我的connect.php:
$mysql_hostname = "localhost";
$mysql_username = "root";
$mysql_password = "xxxxxxxx";
$mysql_database = "marrybrown_clean";
$bd = mysqli_connect ($mysql_hostname, $mysql_username, $mysql_password) or die ('Could not connect database!');
mysqli_select_db ($mysql_database, $bd) or die (" Could not select database!");
我收到以下错误:
**Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in C:\xampp\htdocs\marrybrown_clean\connect.php on line 7
Could not select database!**
如何解决?
答案 0 :(得分:2)
这一行
click
应该是
.directive('mdChips', function($timeout) {
return {
restrict: 'E',
require: 'mdChips', // Extends the original mdChips directive
link: function(scope, element, attributes, mdChipsCtrl) {
var mouseUpActions = [];
mdChipsCtrl.onInputBlur = function(event) {
this.inputHasFocus = false;
mouseUpActions.push((function() {
var chipBuffer = this.getChipBuffer();
if (chipBuffer != "") { // REQUIRED, OTHERWISE YOU'D GET A BLANK CHIP
this.appendChip(chipBuffer);
this.resetChipBuffer();
}
}).bind(this));
};
window.addEventListener('click', function(event) {
while (mouseUpActions.length > 0) {
var action = mouseUpActions.splice(0, 1)[0];
$timeout(function() {
$timeout(action);
});
}
}, false);
}
}
})
链接(mysqli_select_db ($mysql_database, $bd)
)位于mysqli_select_db ($bd, $mysql_database)
个函数中。
答案 1 :(得分:1)
mysqli_select_db要求第一个参数为mysqli_connect();所以应该如下。
mysqli_select_db ($bd, $mysql_database)
答案 2 :(得分:0)
mysqli_selct_db
中的第一个参数是连接参数,唯一错误的是你有互换变量。
所以这一行:
mysqli_select_db ($mysql_database, $bd);
需要替换为:
mysqli_select_db ($bd, $mysql_database);
你也可以这样做:
$mysqli = mysqli_connect
($mysql_hostname,$mysql_username,$mysql_password,$mysql_database)
or die('Could not connect to database!');
答案 3 :(得分:0)
建议您在连接时选择数据库:
$mysqli = mysqli_connect
($mysql_hostname,$mysql_username,$mysql_password,$mysql_database)
or die('Could not connect to database!');
您还可以使用面向对象的样式:
$mysqli = new mysqli
($mysql_hostname,$mysql_username,$mysql_password,$mysql_database);
答案 4 :(得分:0)