MySQL Forums
Forum List  »  PHP

mysql to mysqli
Posted by: Fernando Madson Rocha Fernando
Date: April 03, 2018 10:34PM

i need change mysql to mysqli, help pls

<?php
$realms = array(
// "Realm name" => array(realmd_DB, characters_DB, mangos_DB, armory_DB)
"Wolkrania TBC" => array(1, 1, 1, 1),
"Wolkrania WOTLK" => array(2, 2, 2, 2),
//"Your Realm Name 3" => array(3, 3, 3, 3),
);
// Default Realm Name (use one chosen upper in $realms)
define("DefaultRealmName", "Wolkrania TBC");
$realmd_DB = array(
// Connection to realmd DBs
array("127.0.0.1:3306", "root", "xxxxx", "auth"),
//2 => array("127.0.0.2:3306", "root", "xxxxx", "auth"),
//3 => array("127.0.0.3:3306", "root", "root_pass", "realmd3"),
);
$characters_DB = array(
// Connection to characters DBs
1 => array("127.0.0.1:3306", "root", "xxxxx", "characters_tbc"),
2 => array("127.0.0.2:3306", "root", "xxxxx", "characters"),
//3 => array("127.0.0.3:3306", "root", "root_pass", "characters3"),
);
$mangosd_DB = array(
// Connection to mangos DBs
1 => array("127.0.0.1:3306", "root", "xxxxx", "world_tbc"),
2 => array("127.0.0.2:3306", "root", "xxxxx", "world"),
//3 => array("127.0.0.3:3306", "root", "root_pass", "mangos3"),
);
$armory_DB = array(
// Connection to armory DBs
1 => array("127.0.0.1:3306", "root", "xxxxx", "armory_wotlk"),
2 => array("127.0.0.2:3306", "root", "xxxxx", "armory_tbc"),
//3 => array("127.0.0.3:3306", "root", "root_pass", "armory3"),
);
/* Don't touch anything beyond this point. */
set_time_limit(0);
ini_set("default_charset", "UTF-8");
set_magic_quotes_runtime(false);
function execute_query($query, $error = "")
{
$query_result = @mysql_query($query);
if($query_result)
return $query_result;
else
{
die($error.mysql_error());
return false;
}
}
function switchConnection($db_type, $realm_name)
{
global $realms, $realmd_DB, $characters_DB, $mangosd_DB, $armory_DB;
switch($db_type)
{
case "realmd": $needed_db = $realmd_DB[$realms[$realm_name][0]]; break;
case "characters": $needed_db = $characters_DB[$realms[$realm_name][1]]; break;
case "mangos": $needed_db = $mangosd_DB[$realms[$realm_name][2]]; break;
/* armory */default: $needed_db = $armory_DB[$realms[$realm_name][3]];
}
mysql_connect($needed_db[0], $needed_db[1], $needed_db[2]) or die("Unable to connect to SQL host of ".$db_type." DB of realm ".$realm_name.": ".mysql_error());
mysql_select_db($needed_db[3]) or die("Unable to connect to ".$db_type." DB of realm ".$realm_name.": ".mysql_error());
execute_query("SET NAMES 'utf8'");
}
?>

Options: ReplyQuote


Subject
Written By
Posted
mysql to mysqli
April 03, 2018 10:34PM
April 03, 2018 11:00PM
April 14, 2018 08:59AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.