如果有人能告诉我如何为 mysqli 替换/修复它,我将不胜感激。这是两个示例,因此我可以从中学习并修复所需的所有内容。
样品 1:
include dirname(__FILE__) . '/database.php';
mysql_select_db(databasename, mysql_connect(server, user, pass));
$q_settings = mysql_query("SELECT * FROM settings");
$settings = array();
while ($setting_one = mysql_fetch_array($q_settings)) {
$settings[$setting_one["name"]] = $setting_one["value"];
}
样本 2:
$one_blog = mysql_fetch_array(mysql_query("SELECT * FROM blog WHERE id = '" . mysql_real_escape_string($_GET["id"]) . "' LIMIT 1"));
感谢您提供任何提示和示例。我已经尝试了一些来自 php.net 用户评论的示例,但在某些情况下我失败了。这就是我所做的。
$db_select = mysqli_connect(server, user, pass, databasename) or die("Error " . mysqli_error($db_select));
$db_query = "SELECT * FROM settings";
$db_result = $db_select->query($db_query) or die("Error in the consult..." . mysqli_error($db_select));
$settings = array();
while ($setting_one = mysqli_fetch_array($db_result)) {
$settings[$setting_one["name"]] = $setting_one["value"];
}