RTF,IE6和PHP [英] RTF, IE6 and PHP

查看:98
本文介绍了RTF,IE6和PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在谷歌上搜索,rtfm''ing,rtfw''ing并尽我所能

让这个工作。


服务器:

Apache 2.0.50

PHP 4.3.4

PDFLib 4.0.3

MySQL 4.0.17

客户:

Windows XP专业版,Service Pack 2

IE 6.0.28


代码:


<?php

//连接数据库并检索我们需要的记录

$ db = mysql_connect (localhost,root",**********);

mysql_select_db(" EngInfo",$ db);


//获取数据行数

$ query =" SELECT count(*)as count FROM brw";

$ res = mysql_query($ query);

$ row = mysql_fetch_array($ res);

$ numrows = $ row [''count''];


$ result = mysql_query(" SELECT * FROM brw WHERE id = 2 ORDER BY id ASC");


//生成标题帮助ab rowser选择正确的应用程序

header(''Content-type:application / msword'');标题(

''Content-Disposition:inline,filename = brwrep.rtf'');

//打开我们的模板文件

$ filename =''LChace.rtf'';

$ fp = fopen($ filename,''r'');


//阅读我们的模板变量变量

$ output = fread($ fp,filesize($ filename));


fclose($ fp);


while($ myrow = mysql_fetch_array($ result)){


//用我们的数据替换模板中的占位符

$ output = str_replace(''<<< bid>>'',strtoupper($ myrow [''bid'']),$ output

);

$ output = str_replace(''<< bdrep>>'',$ myrow [''bdrep''],$ output);

$ output = str_replace(''< < recdate>>'',$ myrow [''recdate''],$ output);

$ output = str_replace(''<< solic>>'',$ myrow [''solic''],$ output);

$ output = str_replace(''&l t;< closedate>>'',$ myrow [''closedate''],$ output

);

$ output = str_replace(''< < clin>>'',$ myrow [''clin''],$ output);

$ output = str_replace(''<< nsn>>'',$ myrow [''nsn''],$ output);

$ output = str_replace(''<< qty>>'',$ myrow [''qty''],$输出);

$ output = str_replace(''<< nomen>>'',$ myrow [''nomen''],$ output);

$ output = str_replace(''<<< slp>>'',$ myrow [''slp''],$ output);

}

//将生成的文档发送到浏览器

echo $ output;

?>


以上代码通过以下方式调用 http://servername/rtf.php?id = 2 。这个代码

适用于我尝试的每个浏览器,除了IE 6,你不知道吗,

IE6是< cough>首选< / cough>我们局域网上的浏览器。


每当我尝试在IE6下使用这个脚本时,浏览器都希望

下载URL而不是文件名(brwrep.rtf) )。如果我使用Mozilla下载/查看
,一切都很好,我可以保存freakin文件

然后用文字打开它没有问题。

我在谷歌周围旅行,这个新闻组引导我到很多人

有同样的问题,但似乎没有人来过

up一个解决方案。

如何解决这个问题,解决这个问题,或者?


TIA提出任何建议!


rk

I have been googling, rtfm''ing, rtfw''ing and doing everything I can to
get this working.

Server:
Apache 2.0.50
PHP 4.3.4
PDFLib 4.0.3
MySQL 4.0.17

Client:
Windows XP Pro, Service Pack 2
IE 6.0.28

Code:

<?php
// Connect to the DB and retrieve the records we need
$db = mysql_connect("localhost", "root", "**********");
mysql_select_db("EngInfo",$db);

// get the count of the number of rows of data
$query = "SELECT count(*) as count FROM brw";
$res = mysql_query($query);
$row = mysql_fetch_array($res);
$numrows = $row[''count''];

$result = mysql_query("SELECT * FROM brw WHERE id=2 ORDER BY id ASC");

//generate the headers to help a browser choose the correct application
header( ''Content-type: application/msword'' ); header(
''Content-Disposition: inline, filename=brwrep.rtf'');
// open our template file
$filename = ''LChace.rtf'';
$fp = fopen ( $filename, ''r'' );

//read our template into a variable
$output = fread( $fp, filesize( $filename ) );

fclose ( $fp );

while($myrow = mysql_fetch_array($result)) {

// replace the place holders in the template with our data
$output = str_replace( ''<<bid>>'', strtoupper( $myrow[''bid''] ), $output
);
$output = str_replace( ''<<bdrep>>'', $myrow[''bdrep''], $output );
$output = str_replace( ''<<recdate>>'', $myrow[''recdate''], $output );
$output = str_replace( ''<<solic>>'', $myrow[''solic''], $output );
$output = str_replace( ''<<closedate>>'', $myrow[''closedate''], $output
);
$output = str_replace( ''<<clin>>'', $myrow[''clin''], $output );
$output = str_replace( ''<<nsn>>'', $myrow[''nsn''], $output );
$output = str_replace( ''<<qty>>'', $myrow[''qty''], $output );
$output = str_replace( ''<<nomen>>'', $myrow[''nomen''], $output );
$output = str_replace( ''<<slp>>'', $myrow[''slp''], $output );
}
// send the generated document to the browser
echo $output;
?>

The above code is called via http://servername/rtf.php?id=2. This code
works with every browser I try EXCEPT IE 6 and wouldn''t you know it,
IE6 is the <cough>preferred</cough> browser on our LAN.

Whenever I attempt to use this script under IE6, the browser wants to
download the URL instead of the filename (brwrep.rtf). If I
download/view with Mozilla, all is well, I can save the freakin file
and then open it with word without issue.

My travels around google and this news group lead me to a lot of folks
having the same problem, however it would appear that nobody has come
up with a solution.
HOW/CAN this be fixed, worked around or?

TIA for any suggestions!

rk

推荐答案

db = mysql_connect(" localhost"," root"," ******) ****");

mysql_select_db(" EngInfo",
db = mysql_connect("localhost", "root", "**********");
mysql_select_db("EngInfo",


db);


/ /得到数据行数的计数
db);

// get the count of the number of rows of data


query =" SELECT count(*)as count FROM brw" ;;
query = "SELECT count(*) as count FROM brw";


这篇关于RTF,IE6和PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆