下面的代码可能是mysql4.1以前的连接代码,我在用mysql5时,页面输入中文后,页面读出时能正常显示,但是在phpmyadmin中连接的时候,读出的是乱码。(phpmyadmin连接其他数据库,如ph...
下面的代码可能是mysql4.1以前的连接代码,我在用mysql 5时,页面输入中文后,页面读出时能正常显示,但是在phpmyadmin中连接的时候,读出的是乱码。(phpmyadmin连接其他数据库,如phpwind创建的,是正常的。数据库的编码是utf8.)
/**********************************
* Olate Download 3.4.1
* http://www.olate.co.uk/od3
**********************************
* @package od
*
* Updated: $Date: 2006-10-10 20:27:12 +0100 (Tue, 10 Oct 2006) $
*/
// Database Interaction Module
class dbim
{
// Declare the variables
var $connection, $in_query, $name, $password, $persistant, $query_count, $result, $server, $username;
// Connect to database
function connect($username, $password, $server, $name, $persistant)
{
// Populate class variables
$this->username = $username;
$this->password = $password;
$this->server = $server;
$this->name = $name;
$this->persistant = $persistant;
// Connect
$this->connection = ($this->persistant) ? @mysql_pconnect($this->server, $this->username, $this->password, 1) : @mysql_connect($this->server, $this->username, $this->password, 1);
// If everything was ok, select database
if ($this->connection)
{
if (@mysql_select_db($this->name))
{
return $this->connection;
}
}
// Error handling (If you have EHM debug >= 2 then you get a full var dump including DB access details)
trigger_error('[DBIM] Connection Failed: '.mysql_error(), FATAL);
}
// Execute and return result of SQL query
function query($query = false)
{
if (isset($query))
{
// Make sure we're not already running a query 'cause it may break
if (!$this->in_query)
{
$this->in_query = true;
$this->result = @mysql_query($query, $this->connection);
if (!$this->result)
{
// Error handling
trigger_error('[DBIM] Query Failed: '.mysql_error().' Query: '.$query, FATAL);
}
// Increment query counter
$this->query_count++;
$this->in_query = false;
return $this->result;
}
else
{
// Error handling
trigger_error('[DBIM] Already in query', FATAL);
}
}
// Error handling
trigger_error('[DBIM] No Query Specified', FATAL);
}
// Return result row as an associative array
function fetch_array($result)
{
return ($result) ? @mysql_fetch_assoc($result) : trigger_error('[DBIM] Query Failed: '.mysql_error(), FATAL);
}
}
?>
请问如何才能都正常显示?
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
展开