<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ok</title>
</head>
<body>
<?php
//========================連結數據庫==================$emp_host="192.168.0.43";
$emp_user="postgres";
$emp_password="postgres";
$emp_dbname="mydb";
$pg=pg_connect("host=$emp_host user=$emp_user password=$emp_password dbname=$emp_dbname port=5432" );
//===========================INSERT===================$sql="set client_encoding to utf8;insert into biao(username,password) values('好','119')";$result=pg_query($pg,$sql);
if ($result)
{echo "sucessfully";
echo pg_affected_rows($result);
}上述代码那里错了。在服务器端用sql语句可插入中文到数据库,数据库编码utf8.
为什么执行该页面报以下错:Warning: pg_query() [function.pg-query]: Query failed: ERROR: invalid byte sequence for encoding "UTF8": 0x8d HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding". in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\ps.php on line 58