我使用了一种不好的方法来连接到我的mysql数据库吗? 我目前使用的是:通过php连接到mysql的最佳方法
$con = mysql_connect("localhost","username","password");
mysql_select_db("mysql_table", $con);
我使用了一种不好的方法来连接到我的mysql数据库吗? 我目前使用的是:通过php连接到mysql的最佳方法
$con = mysql_connect("localhost","username","password");
mysql_select_db("mysql_table", $con);
使用ADODB库。连接的代码看起来像:
$db = ADONewConnection('mysqlt');
$db->Connect($db_host, $db_username, $db_password, $db_name);
$db->SetFetchMode(ADODB_FETCH_ASSOC);
您可以轻松地做准备的语句:
// $sql is your sql statement
// $sqlArray is an array of user entered variables
$query = $db->execute($sql, $sqlArray);
可以很容易地获得数据:
$row = $query->FetchRow();
是。您应该切换到使用mysqli或PDO - mysql_函数已被软弃用,并最终被删除。 mysqli_和PDO允许您使用预准备语句,消除了SQL注入的风险。您可以在PHP手册中找到关于这些扩展的更多信息。
标志指向是,该API已被弃用。 –