希望大家帮忙看看,这段小程序做查询和插入,条件用字符串就行,用汉字就不能。
风飘花 2008-09-01 01:39:20 php5.2.6 default_charset "utf-8"
apache2.2.9 配置为
PHPIniDir "D:/php"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .htm .html
DefaultLanguage zh-CN
AddLanguage zh-CN .zh-cn
AddCharset gb2312 .gb2312 .gb
mysql 是utf-8
<?php
@ $db = new mysqli("localhost", "root", "disnio", "stu");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
//$ins="insert into stus values(012, ‘花卉’, 16, '1994-11-07', 2.5, 9)";
//这里如果把花卉换成是字符串的如:huahui就能通过了,但用汉字就不行。请大家帮忙解决下。谢谢
$ins = "select * from stus where stuname='花卉'";
//$result = $db->query($ins);
if ($result = $db->query($ins)) {
/* fetch object array */
while ($row = $result->fetch_row()) {
printf ("%s (%s)\n", $row[0], $row[1]);
}
/* free result set */
$result->close();
}
//if(result)
//echo $db->affected_rows.' is inserted into database.';
/* close connection */
$db->close();
?>