

Připojení k mysql
Dobrý den. Chtěl bych toto "set names 'cp1250'" vložit k připojení k mysql. Kam to mám dát? Děkuji
<?PHP
// This class handles database communication
class x7chat_db {
var $con; // MySql resource
var $database; // MySql database resource
var $error; // Stores error message (used for install file and debugging)
// This function handles running a query
function DoQuery($query){
global $_COOKIE, $MUSE_DB;
$q = mysql_query($query,$this->con); // Run the query
if(mysql_error() == ""){ // If MySql doesn't sends back an error then
return $q; // return resource ID
}else{
if(eregi("max_questions",mysql_error())){
// Switch users, this ones done with for an hour
$MUSE_DB['current']++;
if(!isset($MUSE_DB["user_{$MUSE_DB['current']}"])) {
// O damn we're out of users, error out
echo "MUSE Error - Out of Users!";
exit;
}
$this->x7chat_db();
return $this->DoQuery($query);
}else{
return mysql_error(); // otherwise return the error
}
}
}
// Get a row from the database
function Do_Fetch_Row($q){
$row = mysql_fetch_row($q); // Get the row
return $row; // Return it
}
// Make the database connection and select the correct database
function x7chat_db($host="",$uname="",$pword="",$db="",$die =1){
global $X7CHAT_CONFIG, $MUSE_DB; // Get the values from the config file
if($host == ""){
$host = $X7CHAT_CONFIG['DB_HOST'];
$uname = $MUSE_DB["user_{$MUSE_DB['current']}"];
$pword = $MUSE_DB["pass_{$MUSE_DB['current']}"];
$db = $X7CHAT_CONFIG['DB_NAME'];
}
$this->error = 0;
if($X7CHAT_CONFIG['USE_PCONNECT'] == 1){
$this->con = @mysql_pconnect($host,$uname,$pword);
}else{
$this->con = @mysql_connect($host,$uname,$pword);
}
$this->database = @mysql_select_db($db,$this->con); // Select the database
if(!$this->con){
if($die){
die("Error connecting to database"); // If it fails print an error and exit
}else{
$this->error = 2;
return;
}
}
if(!$this->database){
if($die){
die("Error selecting database"); // If it fails print an error and exit
}else{
$this->error = 3;
return;
}
}
}
}
?>
Pre vkladanie zdrojových kódov používaj tag code, ty programátor. Skús sem dávať aj trochu menej triviálnych otázok najmä po tom, čo si nám tu predvčerom predviedol, lebo trpezlivosť nie je nekonečná.
Trochu sa zamysli, že prečo to tam vlastne chceš vložiť, čo tým chceš dosiahnuť. Ale keďže zajtra musíš do školy a dovtedy by si na to asi neprišiel, tak to vlož na koniec funkcie x7chat_db.
Ak sa chceš niečo naučiť, tak si prečítaj dokumentáciu k funkcii mysql_set_charset. Značím ako vyriešené, neni zač.