php - Replacement for deprecated function mysql_connect -
this question has answer here:
- mysqli or pdo - pros , cons? [closed] 13 answers
so have amazon web service database set up
i'm working off old tutorial application i'm planning on using with.
i noticed mysql_connect deprecate when looked up.
what can use alternative? how can connect amazon database?
<? mysql_connect("localhost", "username", "password") or die ("can't connect database server"); mysql_select_db("videorecorderdemo") or die ("can't select database"); mysql_query("set names 'utf8'"); ?>
i error:
warning: mysql_connect() [function.mysql-connect]: access denied 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 database server
no matter credentials use. doesn't amazon's code samples show connecting in entirely different way.
this extension deprecated of php 5.5.0, , removed in future. instead, mysqli or pdo_mysql extension should used.
$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'my_db'); /* * "official" oo way it, * $connect_error broken until php 5.2.9 , 5.3.0. */ if ($mysqli->connect_error) { die('connect error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error); }
Comments
Post a Comment