参见英文答案 > mysqli or PDO – what are the pros and cons? [closed] 13个
所以我已经设置了这个Amazon Web Service数据库
我注意到MysqL_connect在我查找时已经弃用了.
我可以用什么作为替代品?如何连接到我的亚马逊数据库?
<?
MysqL_connect("localhost", "username", "password") or die ("Can't connect to database server");
MysqL_select_db("videoRecorderDemo") or die ("Can't select database");
MysqL_query("SET NAMES 'utf8'");
?>
我收到此错误:
Warning: MysqL_connect() [function.mysql-connect]: Access denied for user 'username'@'192.168.1.1' (using password: YES) in /www/zxq.net/r/e/d/red5vptest/htdocs/utility/db.PHP on line 2
Can't connect to database server
无论我使用什么凭据.
亚马逊的代码示例显示您以完全不同的方式连接也无济于事.
解决方法:
The documentation for PHP says
This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the 07001 or 07002 extension should be used.
$MysqLi = new MysqLi('localhost', 'my_user', 'my_password', 'my_db');
/*
* This is the "official" OO way to do it,
* BUT $connect_error was broken until PHP 5.2.9 and 5.3.0.
*/
if ($MysqLi->connect_error) {
die('Connect Error (' . $MysqLi->connect_errno . ') '
. $MysqLi->connect_error);
}