Mysqli查询并选择数据库警告

时间:2014-07-23 05:39:21

标签: php mysqli

所以我有这个代码,我的浏览器给了我警告。代码在这里:

47  mysqli_select_db($database_connHotel, $connHotel);
48  $Result1 = mysqli_query($insertSQL, $connHotel) or die(mysqli_error($connHotel));

警告在这里:

Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in /Applications/MAMP/htdocs/add_user.php on line 47

Warning: mysqli_query() expects parameter 1 to be mysqli, string given in /Applications/MAMP/htdocs/add_user.php on line 48

我不理解这些警告,并需要帮助我如何在本周末之前为项目修复它。提前感谢您的帮助!

2 个答案:

答案 0 :(得分:3)

对于这两个函数来说,MySQL连接对象是第一个变量:

mysqli_select_db($connHotel, $database_connHotel);

另外,

mysqli_query($connHotel, $insertSQL)

<强>参考:
http://php.net/manual/en/mysqli.select-db.php
http://php.net/manual/en/mysqli.query.php

*mysql_* functions are not just converted to mysqli_* functions just by placing an 'i' at the end. Most of them have different set of parameters, please try having a brief search before using mysqli_* functions.

答案 1 :(得分:0)

mysqli_select_db ( mysqli $link , string $dbname )

链接

A link identifier returned by mysqli_connect().

<强> DBNAME

The database name.

所以像这样使用mysqli_select_db($connHotel, $database_connHotel);