懂JS和PHP的进 乱码问题 100分 我磕头了~~55555555

TCP_IP 2005-10-18 07:32:25
我是PHP的初学者
为了做一个PW论坛的引用直接到快速回复栏做了好久都没成功
今天总算有了突破 可是出现了乱码问题
首先我写了一个getquote.php(功能是通过PID可以查询到某个贴的时间 作者 内容 并按一定的格式返回)

效果是这样的:
http://anime.62m.net/getquote.php?pid=501

他的源代码是这样的(不完善 只能显示非顶楼的 我昨天才学啊 55555555)

<?php
require_once('global.php');
if($article==0){
$atcarray=$tpcarray?
} else{
!is_numeric($pid) && showmsg('illegal_tid');
$atcarray = $db->get_one("SELECT author,subject,ifsign,postdate,content FROM pw_posts WHERE pid='$pid'");
}
$ifsign=$atcarray['ifsign'];
$old_author=$atcarray['author'];
$replytitle=$atcarray['subject'];
$wtof_oldfile=get_date($atcarray['postdate']);
require_once GetLang('post');
$old_content=stripslashes($atcarray['content']);
$old_content=preg_replace("/\[hide=(.+?)\](.+?)\[\/hide\]/is",$lang['hide_post'],$old_content);
$old_content=preg_replace("/\[post\](.+?)\[\/post\]/is",$lang['post_post'],$old_content);
$old_content=preg_replace("/\[sell=(.+?)\](.+?)\[\/sell\]/is",$lang['sell_post'],$old_content);
$old_content=preg_replace("/\[quote\](.*)\[\/quote\]/is","",$old_content);

if(strpos($old_content,$db_bbsurl)!==false){
$old_content=str_replace('p_w_picpath',$picpath,$old_content);
}
//

$bit_content = explode("\n",$old_content);
if (count($bit_content) > 5){
$old_content = "$bit_content[0]\n$bit_content[1]\n$bit_content[2]\n$bit_content[3]\n$bit_content[4]\n.......";
}
//
if(strpos($old_content,$db_bbsurl)!==false){
$old_content=str_replace('p_w_picpath',$picpath,$old_content);
$old_content=str_replace('p_w_upload',$attachpath,$old_content);
}
//
$old_content=preg_replace("/\<(.+?)\>/eis","",$old_content);
if($winddb['editor']){
$atc_content="
引用
".$lang['info_post']."\n{$old_content}
\n";
} else{
$atc_content="
引用
".$lang['info_post']."\n{$old_content}
\n";
}
echo $atc_content;
?>


虽然不能显示顶楼 但是其他回帖都没有问题

然后呢。。。

我写了一个JS文件

是这样的:取名为greedland.js

var uniqnum_counter = (new Date).getTime();
function UniqueNum() {
++uniqnum_counter;
return uniqnum_counter;
}

function XHConn()
{
var xmlhttp, bComplete = false;
try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e) { try { xmlhttp = new XMLHttpRequest(); }
catch (e) { xmlhttp = false; }}}
if (!xmlhttp) return null;

this.quote = function(sURL,sVars)
{
if (!xmlhttp) return false;
bComplete = false;
try {
xmlhttp.open("GET", sURL+"?"+sVars+ "&rand=" + UniqueNum(), true);
sVars = "";
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && !bComplete)
{
bComplete = true;
d = xmlhttp.responseText;
document.FORM.atc_content.focus();
document.FORM.atc_content.value+=d;
document.FORM.atc_content.value+="大家好~~~\r\n\r\n";
document.FORM.atc_content.focus();
}};
xmlhttp.send(null);
}
catch(z) { return false; }
};

return this;
}
var myConn = new XHConn();
if (!myConn) alert("你的浏览器不支持xmlhttp技术,您将无法使用本站的某些功能,请尝试新版本的浏览器。");


之后

我就可以在相应的论坛相应引用符号处

写成

<a href=### class=white onClick="myConn.quote('getquote.php','fid=$fid&tid=$tid&pid=$read[pid]&article=$read[lou]');return false;"><img src='$imgpath/$stylepath/read/quote.gif' align=absmiddle alt='引用回复这个帖子'></a>


修改好一切以后 我点引用

内容就能按照格式出现在快速回复栏中了

可是...

出现的竟然是乱码

我哭啊~~~~~

谁能帮我解决 可以到我的论坛看具体的效果(开放了游客的)

http://anime.62m.net/read.php?tid=149&fpage=1

论坛现在运行中 所有引用我改回去了 不过快速回复栏旁边有一个测试按钮1 你点一下就能看到具体的效果了。。。。

有个论坛用的和我一样的JS文件能正常显示

他的get_quote.php文件访问时时这样的效果:

http://bbs.greedland.net/get_quote.php?postId=31181008&topicId=656860&forumId=8
...全文
358 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
TCP_IP 2005-10-18
  • 打赏
  • 举报
回复
哈哈 我爱你 ~ 谢谢 分全给你了 如果你有时间能帮我写一下怎么解决顶楼问题吗?

ezdevelop 2005-10-18
  • 打赏
  • 举报
回复
@header('Content-type: text/html;charset=GBK');
TCP_IP 2005-10-18
  • 打赏
  • 举报
回复
我加在这句前面
@header('Content-type: text/html;charset=GBK);
echo $atc_content;

==

我真的时初学 你能说清楚点么 我这个都是根据自己以前对其他程序的感觉 东捞西凑搞出来的==
TCP_IP 2005-10-18
  • 打赏
  • 举报
回复
怎么加 我加在那句前面变成这样了
http://anime.62m.net/getquote.php?pid=501

Parse error: parse error, unexpected $ in /home/anime/public_html/getquote.php on line 43
ezdevelop 2005-10-18
  • 打赏
  • 举报
回复
这是因为XMLHTTP默认是采用UTF-8格式传输

你可在'getquote.php'文件输出前加句@header('Content-type: text/html;charset=GBK);

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧