程序为: $db = new mysqli('localhost:3306','bookorama','bookorama123','books');提示:PHP Warning: mysqli::mysqli() [mysqli.mysqli]: (28000/1045): Access denied for user 'bookorama'@'localhost' (using password: YES) in D:\php网站\results.php on line 24 PHP Warning: mysqli::query() [mysqli.query]: Couldn't fetch mysqli in D:\php网站\results.php on line 36 PHP Notice: Trying to get property of non-object in D:\php网站\results.php on line 38 PHP Fatal error: Call to a member function free() on a non-object in D:\php网站\results.php on line 55
header("content-type:text/html;charset:utf-8");class MysqlConn{
const SERVERNAME = "localhost:3306";
const USERNAME = "root";
const PASSWORD = "111111";
const MYSQLDB = "MovieSpecialtyArea"; function conn(){
//常量与静态变量一样,用"self::"调用
$mysqli = new mysqli(self::SERVERNAME,self::USERNAME,self::PASSWORD,self::MYSQLDB);
//检查数据库连接
if (mysqli_connect_error()){
printf("数据库连接失败:",mysqli_connect_error());
exit;
}else{
//返回结果,为了实例化对象的调用
return $mysqli;
} }}
需要到mysql中进行grant操作。To LZ,联系你的DBA吧,这个操作对于你来说有点难...
密码错了吧
服务器是否允许localhost?