ID字段:id 问题标题字段:title 提问时间字段:dateline 问题内容字段: ontent
我下面的代码怎么读不出字段内容啊?
大大们帮忙检查下看看啊 谢谢啊<? require("connection.php"); ?>
<? require("tools.php"); ?>
<? //require("checkpass.php"); ?>
<?
$search = "";
if($id<>""){
if($search==""){
$search .= " WHERE ";
}else{
$search .= " AND ";
}
$search .= " id = '" . $id . "' ";
}
if($title<>""){
if($search==""){
$search .= " WHERE ";
}else{
$search .= " AND ";
}
$search .= " title = '" . $title . "' ";
}
if($dateline<>""){
if($search==""){
$search .= " WHERE ";
}else{
$search .= " AND ";
}
$search .= " dateline = '" . $dateline . "' ";
}
if($content<>""){
if($search==""){
$search .= " WHERE ";
}else{
$search .= " AND ";
}
$search .= " content = '" . $content . "' ";
}
$table="dede_ask";
$sql="select * from " . $table . $search ." order by id DESC";
//echo $sql;exit();
$result=mysql_query($sql);
$pagesize=25; //每页记录条数
$result_num=mysql_num_rows($result);
if($result_num<=0){
if($search==""){
$word="目前还没有记录!";
}else{
$word="没有查到符合条件的记录!";
}
}else{
$maxpage=ceil($result_num/$pagesize); if(is_long($page) or $page==""){
$page=1;
}else{
$page=(int)($page);
}
if($page<1){
$page=1;
}else if( $page>$maxpage){
$page=$maxpage;
}
mysql_data_seek($result,($page-1)*$pagesize);
$n=1;
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="style.css">
<title></title>
</head>
<body bgcolor="#FFFFFF" topmargin="0" leftmargin="0">
<? require("top.inc"); ?>
<? if($result_num<=0){ ?>
<center><BR><BR><? print($word); ?></center>
<? }else{ ?>
<table width="598" border="0" cellspacing="2" cellpadding="0" align="center">
<tr>
<td>共搜索到<font color="#FF0000"><? print($result_num); ?></font>条符合条件的信息</td>
</tr>
</table>
<table width="600" border="0" cellspacing="1" cellpadding="0" align="center">
<tr align=center bgcolor=#97D0FB>
<td><b>ID</b></td>
<td><b>问题</b></td>
<td><b>提问时间</b></td>
<td><b>修改</b></td>
</tr>
<? while($row = mysql_fetch_array($result)){ ?>
<tr bgcolor=#EEF8FD>
<td align=center><a href="renaiask_show.php?id=<? print($row["id"]); ?>"><? print(HtmlOut($row["id"])); ?></a></td>
<td align=center><? print(HtmlOut($row["title"])); ?></td>
<td align=center><? print(HtmlOut($row["dateline"])); ?></td>
<td>
<div align="center"><a href="renaiask_join.php?editid=<? print(HtmlOut($row["id"])); ?>">编辑</a></div>
</td>
</tr>
<? $n++;if(!($row = mysql_fetch_array($result)) || $n > $pagesize) break; ?>
<tr bgcolor=#D7EFFB>
<td align=center><a href="renaiask_show.php?id=<? print($row["id"]); ?>"><? print(HtmlOut($row["id"])); ?></a></td>
<td align=center><? print(HtmlOut($row["title"])); ?></td>
<td align=center><? print(HtmlOut($row["dateline"])); ?></td>
<td>
<div align="center"><a href="renaiask_join.php?editid=<? print(HtmlOut($row["id"])); ?>">编辑</a></div>
</td>
</tr>
<? $n++;if($n > $pagesize) break;} ?>
</table>
<? LastNextPage($maxpage,$page,"width=100% ","<p align=center class=font2>"); ?>
<? } ?>
<? require("bottom.inc"); ?>
</body>
</html>
我下面的代码怎么读不出字段内容啊?
大大们帮忙检查下看看啊 谢谢啊<? require("connection.php"); ?>
<? require("tools.php"); ?>
<? //require("checkpass.php"); ?>
<?
$search = "";
if($id<>""){
if($search==""){
$search .= " WHERE ";
}else{
$search .= " AND ";
}
$search .= " id = '" . $id . "' ";
}
if($title<>""){
if($search==""){
$search .= " WHERE ";
}else{
$search .= " AND ";
}
$search .= " title = '" . $title . "' ";
}
if($dateline<>""){
if($search==""){
$search .= " WHERE ";
}else{
$search .= " AND ";
}
$search .= " dateline = '" . $dateline . "' ";
}
if($content<>""){
if($search==""){
$search .= " WHERE ";
}else{
$search .= " AND ";
}
$search .= " content = '" . $content . "' ";
}
$table="dede_ask";
$sql="select * from " . $table . $search ." order by id DESC";
//echo $sql;exit();
$result=mysql_query($sql);
$pagesize=25; //每页记录条数
$result_num=mysql_num_rows($result);
if($result_num<=0){
if($search==""){
$word="目前还没有记录!";
}else{
$word="没有查到符合条件的记录!";
}
}else{
$maxpage=ceil($result_num/$pagesize); if(is_long($page) or $page==""){
$page=1;
}else{
$page=(int)($page);
}
if($page<1){
$page=1;
}else if( $page>$maxpage){
$page=$maxpage;
}
mysql_data_seek($result,($page-1)*$pagesize);
$n=1;
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="style.css">
<title></title>
</head>
<body bgcolor="#FFFFFF" topmargin="0" leftmargin="0">
<? require("top.inc"); ?>
<? if($result_num<=0){ ?>
<center><BR><BR><? print($word); ?></center>
<? }else{ ?>
<table width="598" border="0" cellspacing="2" cellpadding="0" align="center">
<tr>
<td>共搜索到<font color="#FF0000"><? print($result_num); ?></font>条符合条件的信息</td>
</tr>
</table>
<table width="600" border="0" cellspacing="1" cellpadding="0" align="center">
<tr align=center bgcolor=#97D0FB>
<td><b>ID</b></td>
<td><b>问题</b></td>
<td><b>提问时间</b></td>
<td><b>修改</b></td>
</tr>
<? while($row = mysql_fetch_array($result)){ ?>
<tr bgcolor=#EEF8FD>
<td align=center><a href="renaiask_show.php?id=<? print($row["id"]); ?>"><? print(HtmlOut($row["id"])); ?></a></td>
<td align=center><? print(HtmlOut($row["title"])); ?></td>
<td align=center><? print(HtmlOut($row["dateline"])); ?></td>
<td>
<div align="center"><a href="renaiask_join.php?editid=<? print(HtmlOut($row["id"])); ?>">编辑</a></div>
</td>
</tr>
<? $n++;if(!($row = mysql_fetch_array($result)) || $n > $pagesize) break; ?>
<tr bgcolor=#D7EFFB>
<td align=center><a href="renaiask_show.php?id=<? print($row["id"]); ?>"><? print(HtmlOut($row["id"])); ?></a></td>
<td align=center><? print(HtmlOut($row["title"])); ?></td>
<td align=center><? print(HtmlOut($row["dateline"])); ?></td>
<td>
<div align="center"><a href="renaiask_join.php?editid=<? print(HtmlOut($row["id"])); ?>">编辑</a></div>
</td>
</tr>
<? $n++;if($n > $pagesize) break;} ?>
</table>
<? LastNextPage($maxpage,$page,"width=100% ","<p align=center class=font2>"); ?>
<? } ?>
<? require("bottom.inc"); ?>
</body>
</html>
print_r($result);
sql語句有問題嗎???
可能是字段的问题 我数据库的编码也是gbk的啊
应该是 mysql_query('set names "utf8"');//不是 utf-8
显示????????只是一个代替的,是因为没有读出字段内容被问号替代了啊
那么为什么整个页面所有和数据库无关的文字都是正常的呢?
而只有在读取数据库表内容的时候才会用问号替代呢?
如果是编码的问题,应该不是所有的文字都显示问号吧?
为什么我把
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
改成
<meta http-equiv="Content-Type" content="text/html; charset=UTF_8">
后
浏览整个页面的文字是乱七八糟的呢?
if(check_value != ""){
alert(check_value)
return false;
}
return true;
}function checkvalue(obj, low, up, mode, lable){
/*
Mode = 1 检测是否为空 2是否是数字 4是否整数
8是否是为数字、字母和_.-
16 自定义字符检测
32 长度检测
64 数字大小检测
*/
var temp,type;
var length, i, base, str;
str=getformvalue(obj);
if(str==null){
lenght=0;
str="";
}
else{
length = str.length
}
temp=""
if( mode % 2 >= 1 ){
if( str == "" ){
temp = temp + "“" + lable + "”" + "不能为空!" + "\n";
}
}
if( mode % 4 >= 2 ){
base = "0123456789."
for(i = 0;i<=length-1;i++)
if( base.indexOf(str.substring(i, i+1)) == -1 ){
temp = temp + "“" + lable + "”" + "必需是数字!" + "\n";
break;
}
}
if( mode % 8 >= 4 ){
base = "0123456789"
for(i = 0;i<=length-1;i++)
if( base.indexOf(str.substring(i, i+1)) == -1 ){
temp = temp + "“" + lable + "”" + "必需是整数!" + "\n";
break;
}
}
if( mode % 16 >= 8 ){
base = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789_-."
for(i = 0;i<=length-1;i++)
if( base.indexOf(str.substring(i, i+1)) == -1 ){
temp = temp + "“" + lable + "”" + "包含非法字符!它只能是字母、数字和“- _ .”。" + "\n";
break;
}
}
if( mode % 32 >= 16 ){
base = low.replace("[a-z]", "abcdefghijklmnopqrstuvwxyz")
base = base.replace("[a-z]", "abcdefghijklmnopqrstuvwxyz")
base = base.replace( "[0-9]", "0123456789")
for(i = 0;i<=length-1;i++)
if( base.indexOf(str.substring(i, i+1)) == -1 ){
temp = temp + "“" + lable + "”" + "包含非法字符!它只能是" + up + "。" + "\n";
break;
}
}
if( mode % 64 >= 32 ){
if( ! (length >= low && length <= up) ){
temp = temp + "“" + lable + "”" + "的长度必需在" + low + "到" + up + "之间!" + "\n";
}
}
if( mode % 128 >= 64 ){
if( ! (parseInt(str) >= parseInt(low) && parseInt(str) <= parseInt(up)) ){
temp = temp + "“" + lable + "”" + "必需在" + low + "到" + up + "之间!" + "\n";
} }
if(temp!=""){
alert(temp);
type=(getformtype(obj));
if(type!="radio" && type!="checkbox"){
obj.focus();
}
return false;
}
return true;
}function getformtype(obj){
var type;
type=obj.type;
if(typeof(type)=="undefined"){ type=obj[0].type;
}
return type;
}
function getformvalue(input){
//取表单域的值
var type,temp;
temp="";
type=getformtype(input); switch(type){
case "radio": //单选框
n=input.length-1; if(isNaN(n)==true){
if(input.checked == true){
temp = input.value;
}else{
temp = "";
}
}else{
for(i=0;i<=n;i++){
if(input[i].checked == true){
return(input[i].value);
}
}
break;
}
case "checkbox": //复选框
n=input.length-1;
if(isNaN(n)==true){
if(input.checked == true){
temp = input.value;
}else{
temp = "";
}
}else{
for(i=0;i<=n;i++){
if(input[i].checked == true){
if(temp!=""){
temp += ",";
}
temp += input[i].value; }
}
}
return(temp);
break;
case "select-one" : //单选列表框
n=input.length-1;
for(i=0;i<=n;i++){
if(input.options[i].selected == true){
temp = input.options[i].value;
break;
}
}
return(temp);
break;
case "select-multiple": //多选列表框
n=input.length-1;
for(i=0;i<=n;i++){
if(input.options[i].selected == true){
if(temp!=""){
temp+=",";
}
temp+=input.options[i].value;
}
}
return(temp);
break;
default: //其它
return(input.value);
break;
}
return(input.value);}function ischecked(group,value){
var i,n;
n=group.length-1;
for(i=0;i<=n;i++){
if(value==group[i]){
return true;
}
}
return false;
}
function SetSelectedAndChecked(input,value){
//设置表单域的选择
var type,temp,i,n;
var split_value = new Array();
temp="";
type=input.type;
if(typeof(type)=="undefined"){
type=input[0].type;
}
switch(type){
case "radio": //单选框
n=input.length-1; if(isNaN(n)==true){
if(input.value = value){
input.checked = true;
}else{
input.checked = false;
}
}else{
for(i=0;i<=n;i++){
if(input[i].value == value){
input[i].checked = true;
}else{
input[i].checked = false;
}
}
}
break; case "checkbox": //复选框
n=input.length-1;
split_value=value.split(",");
if(isNaN(n)==true){
if(ischecked(split_value,input.value)){
input.checked = true;
}else{
input.checked = false;
}
}else{
for(i=0;i<=n;i++){
if(ischecked(split_value,input[i].value)){
input[i].checked = true;
}else{
input[i].checked = false;
}
}
}
break;
case "select-one" : //单选列表框
n=input.options.length-1;
for(i=0;i<=n;i++){
if(input.options[i].value == value){
input.options[i].selected = true;
}else{
input.options[i].selected = false;
}
}
break;
case "select-multiple": //多选列表框
n=input.options.length-1;
split_value=value.split(",");
for(i=0;i<=n;i++){
if(ischecked(split_value,input.options[i].value)){
input.options[i].selected = true;
}else{
input.options[i].selected = false;
}
}
break;
default: //其它
return false;
break;
}
return true;}
是不是和这个js文件有关系的啊
我的php文件是gb2312的
我的mysql数据库也是gb2312的呀是因为不行 我才改了utf8了下
另外你说有????????输出那肯定是编码问题,第一保证你的html页面的源代码是gb2312的,而且
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">这也必须是gb2312的
数据库中的编码,和每个数据表中的title字段都有哥编码的,你都要设置为gb2312用mysql的navgate客户端可以设计表结构,点击每个每个字段下面会有一些编码设置,可能编码是itain码,你找找看看
如果还不行那么在DW 编辑的时候 按 F5 键 试试虽然我不知道 在DW 按F5 键 后保存 乱码就解决了 但我就是这样解决的。。
我确实不知道问题是出在什么地方我的title字段类型是:char(80) 整理是:gbk_chinese_ci Null为否希望知道的朋友给能解决问题的方法啊 谢谢了啊
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">我的title字段类型是:char(80) 整理是:gbk_chinese_ci Null为否希望知道的朋友给能解决问题的方法啊 谢谢了啊
下面我把tools.php的整页代码全部贴出来
希望大大们能够帮助一把 谢谢
<?
$key= "R52QLJRHJ43445SDF";
function addnumberforbyte($char,$increment)
{
$temp=$char+$increment+256;
$temp=$temp%256;
return $temp;
}
function encrypt_win($str1)
{
global $key;
$base=$key;
$str=strrev($str1);
$length=strlen($str);
for ($i=1; $i<=$length; $i++)
{
$char = dechex(addnumberforbyte(ord(substr($str,$i-1,1)),ord(substr($base,$i-1,1))));
$temp.=(strlen($char)==1? "0$char":$char);
}
return $temp;
}
function decode_win($str1)
{
global $key;
$base=$key;
$str=$str1;
$length=strlen($str)/2;
for ($i=1; $i<=$length; $i++)
{
$temp.=chr(addnumberforbyte(hexdec(substr($str,($i-1)*2,2)),-(ord(substr($base,$i-1,1)))));
}
return strrev($temp);
}
function htmlencode($str){
return trim(htmlspecialchars($str));
}
function processtj($str,$dw){
$temp=explode(";",$str);
if($temp[0]==""){
if($temp[1]==""){
return "不限";
}else{
return $temp[1].$dw."以下";
}
}else{
if($temp[1]==""){
return $temp[0].$dw."以上";
}else{
return $temp[0]."到".$temp[1].$dw."之间";
}
}
}
function CutStr($str,$length){
//剪切字符串到一定长度,长度以所占字节为准
$len=strlen($str);
if($len<=$length){
return $str;
}else{
$length=$length-3;
$CWordIsOver=1;
for($i=0;$i<=$len-1;$i++){
$temp=substr($str,$i,1);
if(ord($temp)>127) {
$CWordIsOver=-$CWordIsOver;
}
if($i+1==$length){
if($CWordIsOver==-1){
$length--;
}
break;
}
}
return substr($str,0,$length) . "...";
}
}
function outjsmsg($msg){
//输出javascript提示信息并返回
print("<html><body><script language=javascript>\n");
print("<!--\n");
print("alert('$msg');\n");
print("history.back();\n");
print("-->\n");
print("</script></body></html>\n");
return true;
}
function HtmlOut($str){
//将文字转化为它的源代码格式
$guest=$str;
$guest=str_replace(" "," ",$guest);
$guest=str_replace(" ","`nbsp;",$guest);
$Guest=htmlspecialchars($Guest);
$guest=str_replace("`nbsp;"," ",$guest);
$guest=str_replace("\r\n","<BR>",$guest);
return($guest);
}
function LastNextPage($pagecount,$page,$table_style,$font_style){
//生成上一页下一页链接
global $QUERY_STRING,$HTTP_HOST,$SCRIPT_NAME;
$action="http://$HTTP_HOST".$SCRIPT_NAME;
if($QUERY_STRING!=""){
$query = explode("&",$QUERY_STRING);
while(list($index, $value) = each($query)) {
$a = explode("=",$value);
if(strcmp(strtolower($a[0]),"page")!=0){
$temp .= $a[0]."=".$a[1]."&";
}
}
}else{
$temp = "";
}
print("<table " . $table_style . ">\n");
print("<form method=get onsubmit=\"document.location ='" . $action . "?" . $temp . "page='+ this.page.value;return false;\"><tr>\n");
print("<td align=right>\n");
print($font_style ."\n");
if($page<=1){
print ("[第一页] \n");
print ("[上一页] \n");
}else{
print("[<a href=" . $action . "?" . $temp . "page=1>第一页</a>] \n");
print("[<a href=" . $action . "?" . $temp . "page=" . ($page-1) . ">上一页</a>]\n");
}
if($page>=$pagecount){
print ("[下一页] \n");
print ("[最后一页]\n");
}else{
print("[<a href=" . $action . "?" . $temp . "page=" . ($page+1) . ">下一页</a>] \n");
print("[<a href=" . $action . "?" . $temp . "page=" . $pagecount . ">最后一页</a>]\n");
}
print(" 第" . "<input tyep=text name=page maxlength=5 size=2 value=" . $page . ">" . "页\n<input type=submit style=\"font-size: 7pt\" value=GO>\n");
print(" 共 " . $pagecount . " 页\n");
print("</td>\n");
print("</tr></form>\n");
print("</table>\n");
}
function formatDT($dt,$style){
/*
style=0 2000-10-10 下午 12:17:45
style=1 2000-10-10 23:17:45
style=2 2000-10-10 23:45
style=3 00-10-10 23:45
style=4 10-10 23:45
style=5 2000-10-10
style=6 00-10-10
style=7 10-10
*/
$style_str= array(
"Y-m-d A h:i:s",
"Y-m-d H:i:s",
"Y-m-d H:i",
"y-m-d H:i",
"m-d H:i",
"Y-m-d",
"y-m-d",
"h:i");
$temp=date($style_str[$style],$dt);
$temp=($style==0 ? str_replace("AM","上午",str_replace("PM","下午",$temp)):$temp);
return($temp);
}
function outcheck($check_value){
if($check_value != ""){
outjsmsg(str_replace("\n","\\n",$check_value));
exit();
}
}
function checkvalue($str, $low, $up, $mode, $lable){
/*
Mode = 1 检测是否为空 2是否是数字 4是否整数
8是否是为数字、字母和_.-
16 自定义字符检测
32 长度检测
64 数字大小检测
*/
if($str==""){
$lenght=0;
$str="";
}
else{
$length = strlen($str);
}
$temp="";
if( $mode % 2 >= 1 ){
if( $str == "" ){
$temp = $temp . "“" . $lable . "”" . "不能为空!" . "\n";
}
}
if( $mode % 4 >= 2 ){
$base = " 0123456789.";
for($i = 0;$i<=$length-1;$i++)
if( strpos($base,substr($base,i, i+1)) == 0 ){
$temp = $temp . "“" . $lable . "”" . "必需是数字!" . "\n";
break;
}
}
if( $mode % 8 >= 4 ){
$base = " 0123456789";
for($i = 0;$i<=$length-1;$i++)
if( strpos($base,substr($base,i, i+1)) == 0 ){
$temp = $temp . "“" . $lable . "”" . "必需是整数!" . "\n";
break;
}
}
if( $mode % 16 >= 8 ){
$base = " abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789_-.";
for($i = 0;$i<=$length-1;$i++)
if( strpos($base,substr($base,i, i+1)) == 0 ){
$temp = $temp . "“" . $lable . "”" . "包含非法字符!它只能是字母、数字和“- _ .”。" . "\n";
break;
}
}
if( $mode % 32 >= 16 ){
$base = str_replace( $up,"[a-z]", "abcdefghijklmnopqrstuvwxyz");
$base = str_replace( $base,"[a-z]", "abcdefghijklmnopqrstuvwxyz");
$base = str_replace( $base,"[0-9]", "0123456789");
$base = " " . $base;
for($i = 0;$i<=$length-1;$i++)
if( strpos($base,substr($base,i, i+1)) == 0 ){
$temp = $temp . "“" . $lable . "”" . "包含非法字符!它只能是" . $up . "。" . "\n";
break;
}
}
if( $mode % 64 >= 32 ){
if( ! ($length >= $low && $length <= $up) ){
$temp = $temp . "“" . $lable . "”" . "的长度必需在" . $low . "到" . $up . "之间!" . "\n";
}
}
if( $mode % 128 >= 64 ){
if( ! ((int)($str) >= (int)($low) && (int)($str) <= (int)($up)) ){
$temp = $temp . "“" . $lable . "”" . "必需在" . $low . "到" . $up . "之间!" . "\n";
} }
return($temp);
}
?>谁帮我看看 是不是和上面这个叫tools.php的文件有关系呢?
上面我把tools.php的整页代码全部贴出来
希望大大们能够帮助一把 谢谢
而且所有的php文件全部都是gb2312的
为什么会出现编码问题呢?
我把3个相关文件的代码全部贴出来了
我要的是解决方法,39楼朋友答非所问,闲话太多
有本事给出解决方法,分我双手奉上给你,
我知道你也不是指望我这点分,但答非所问,不是CSDN的宗旨,不对么?