mysql_select_db后面怎么写_有人说,在选择数据库mysql_select_db($dbname);后面加上一句mysql_query('set character set gbk');存...

下面的代码可能是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 |

+----------------------+-----------------+

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值