PDA

View Full Version : Need help with this i cant get the mysql connection right


Fronix
01-13-2008, 08:28 PM
Hey i have an error on my webpage that i cant get ridof
<br />
<b>Warning</b>: mysql_select_db() [<a href='function.mysql-select-db'>function.mysql-select-db</a>]: Can't connect to MySQL server on 'localhost' (10061) in <b>C:\Documents and Settings\oskar\My Documents\Web root\Warthwebsite\Armory\configuration\mysql.php</b> on line <b>107</b><br />
<br />
<b>Warning</b>: mysql_select_db() [<a href='function.mysql-select-db'>function.mysql-select-db</a>]: A link to the server could not be established in <b>C:\Documents and Settings\oskar\My Documents\Web root\Warthwebsite\Armory\configuration\mysql.php</b> on line <b>107</b><br />
Unable to connect to Character SQL database: Can't connect to MySQL server on 'localhost' (10061)<br />
<b>Warning</b>: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at C:\Documents and Settings\oskar\My Documents\Web root\Warthwebsite\Armory\configuration\mysql.php:1 07) in <b>C:\Documents and Settings\oskar\My Documents\Web root\Warthwebsite\Armory\index.php</b> on line <b>64</b><br />


Cant get it do go away this is my mysql connection:

<?php
/*
--- MySQL Connection Handler ---
*/
/* --- This is an Example ---
Multirealm Configuration
Array Usage:
"WoDWoW" => array( "ConnectionKey" , "root" , "kickasswow" , "72.233.61.186" , "characters" , "world" ) ,
For example:
$realms = array(
"WoDWoW" => array( "ConnectionKey" , "root" , "kickasswow" , "72.233.61.186" , "character" , "world" ),
);

Note 1: "ConnectionKey" must NOT have any spaces in it, underscores are acceptable.
Note 2: "Char DB" is the database that you use for your characters, NOT your world database.
Note 3: Added the entry for world DB, but it's not operational yet (I.E. Not used)
--- This is an Example ---
*/
/* Set your details here */
$realms = array(
"WoDWoW" => array( "ConnectionKey" , "root" , "kickasswow" , "72.233.61.186" , "character" , "world" ),
);
/* Default Realm if not set */
$realmName["DEFAULT_REALM"] = "Dominance instant 70";
$MySQL_User["DEFAULT_REALM"] = $realms[$realmName["DEFAULT_REALM"]][1];
$MySQL_Password["DEFAULT_REALM"] = $realms[$realmName["DEFAULT_REALM"]][2];
$MySQL_Host["DEFAULT_REALM"] = $realms[$realmName["DEFAULT_REALM"]][3];
$RealmDB["DEFAULT_REALM"] = $realms[$realmName["DEFAULT_REALM"]][4];
$WorldDB["DEFAULT_REALM"] = $realms[$realmName["DEFAULT_REALM"]][5];
/*
Website Database Configuration
-> May or may not have a seperate connection to your realmservers <-
*/
/* RealmDB must be the database used for your item_cache database */
$MySQL_User["WEBSITE"] = "root";
$MySQL_Password["WEBSITE"] = "kickasswow";
$MySQL_Host["WEBSITE"] = "localhost";
$RealmDB["WEBSITE"] = "Armory";
$WorldDB["WEBSITE"] = "World";
/* WorldServer DB if applicable */
$MySQL_User["WSERVER"] = $MySQL_User["DEFAULT_REALM"];
$MySQL_Password["WSERVER"] = $MySQL_Password["DEFAULT_REALM"];
$MySQL_Host["WSERVER"] = $MySQL_Host["DEFAULT_REALM"];
$RealmDB["WSERVER"] = $RealmDB["DEFAULT_REALM"];
$WorldDB["WSERVER"] = $WorldDB["DEFAULT_REALM"]; // ? I seriously can't remember what WSERVER is used for anymore (looks like it's items and playercreateinfo, might be depreceated code tho.. //
/*
Uncommenting these lines is highly unadvisable, especially the 'print_r( $MySQL_Password)' line. Use only on debug/local machines.
print_r( $MySQL_User );
print_r( $MySQL_Password );
print_r( $MySQL_Host );
print_r( $RealmDB );
*/
/* Don't touch anything beyond this point. */
foreach( $realms as $key => $val )
{
$realmName[$val[0]] = $key;
$MySQL_User[$val[0]] = $val[1];
$MySQL_Password[$val[0]] = $val[2];
$MySQL_Host[$val[0]] = $val[3];
$RealmDB[$val[0]] = $val[4];
$WorldDB[$val[0]] = $val[5];
}

function switchDatabase( $realm , $db_type = 'character' )
{
global $RealmDB, $WorldDB, $current_db;
/* This function is called instead of mysql_select_db now that multirealms are implemented */
if( $db_type == 'character' )
{
if( $current_db != sha1( $RealmDB[$realm] ) )
{
mysql_select_db( $RealmDB[$realm] ) or print "Unable to connect to Character SQL database: " . mysql_error();
$current_db = sha1( $RealmDB[$realm] );
}
}
else
{
mysql_select_db( $WorldDB[$realm] ) or print "Unable to connect to World SQL database: " . mysql_error();
$current_db = sha1( $WorldDB[$realm] );
}
}
function switchConnection( $key , $db_type = 'character' )
{
global $MySQL_User, $MySQL_Password, $MySQL_Host, $RealmDB, $WorldDB, $current_connection, $current_db, $querystack;
/* Key - The key of the array used (i.e. $MySQL_User[<key>])*/
if( $current_connection != sha1( $MySQL_Host[$key] ) )
{
$querystack[] = array( "query" => "Connected to " . $key . "." , "time" => 0 , "line" => 0 , "function" => "switchConnection" );
}
if( $db_type == 'character' )
{
if( $current_db != sha1( $RealmDB[$key] ) )
{
mysql_select_db( $RealmDB[$key] ) or print "Unable to connect to Character SQL database: " . mysql_error();
$current_db = sha1( $RealmDB[$key] );
}
}
else
{
mysql_select_db( $WorldDB[$key] ) or print "Unable to connect to World SQL database: " . mysql_error();
$current_db = sha1( $WorldDB[$key] );
}
}
function getConnection()
{
global $current_connection;
return $current_connection;
}
function getDatabase()
{
global $current_db;
return $current_db;
}
/* Default Connection: Website DB */
switchConnection( "WEBSITE" );
switchDatabase( "WEBSITE" );
?>


I have tryed everything it doesent work.

davidj
01-14-2008, 05:53 AM
contact the author of the script and ask him for support

don't know where you got this code from but i advise that copying and pasting stuff which you don't understand is bad practice

that is the most over engineered connection script i have ever seen