php代码查询前需不需要添加什么
<?php
function doDB()
{
$mysqli = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n",mysqli_connect_errno());
exit();
}
}
连接数据库并查询:
<?php
include("link.php");
//connect to server and select database
doDB();
//show categories first
$get_cats_sql = "SELECT id, cat_title, cat_desc FROM forum_categories ORDER BY id";
$get_cats_res = mysqli_query($mysqli, $get_cats_sql) ;
mysql连接校对和数据库的表的整理都已改为utf8_unicode_ci,现在就是不知道页面php代码上如何修改
代码我已经贴出了,能不能说的详细点
追答你页面是什么字符集,你的数据库默认是什么字符集。
如果你知道字符集【例如:utf8】
那么在选择数据库后执行 mysql_query("set names utf8");
数据库字符集是UTF-8 Unicode MySQL 连接校对:utf8_unicode_ci 数据库中表种字段的整理属性也是utf8_unicode_ci 页面的字符集没有设置,也不知道如何设置
追答你以后用 utf8_general
追问那页面字符集怎么设置?写在配合我上述php代码的什么位置?
追答网页页面也要指定字符集
phpmyadmin上查看显示正常,网页上是问号。