生成的rss.xml竟然包含代码错误
_rss.php源代码如下:
<?php
//dim i,link,result;
include_once("../inc/conn.php");
$fp = fopen ("_temp1.xml","r");
$content = fread ($fp,filesize ("_temp1.xml")); //读入打开文件的内容;
$filename = "test/rss.xml"; //拟将rss.xml文件最后生成在test目录下,test目录要具有写权限;
$handle = fopen ($filename,"w"); //fopen,即打开文件,若文件不存在,则自动创建;
if (!is_writable ($filename)){die ("文件:”.$filename.”不可写,请检查其属性后重试!");}
if (!fwrite ($handle,$content)){die ("生成文件".$filename."失败!");}
$i=0;
//$sql = ”SELECT * FROM 'wit_article'”;
$sql="SELECT * FROM wit_article order by art_id desc";
$result = mysql_query($sql,$con);
$k = mysql_num_rows($result);
while( $i<$k )
{
$result1= mysql_query("SELECT * FROM wit_article order by art_id desc limit $i,1");
$a = mysql_fetch_array($result1);
$aid=$a['art_id'];
$cid=$a['art_chaid'];
$i++;
$title = $a['art_title'];
//echo $title;
$link = "http://192.168.1.15/witcms/templates/show.php?cid=$cid&aid=$aid";
//echo $link;
$maintext=$a['art_content'];
$fp = fopen ("_temp2.xml","r");
$content = fread ($fp,filesize ("_temp2.xml"));
$content = str_replace ("{title}",$title,$content); //替换模板变量中的数据;
$content = str_replace ("{link}",$link,$content);
$content = str_replace ("{maintext}",$maintext,$content);
$filename = "test/rss.xml";
$handle = fopen ($filename,"a"); //注意这里是a,不是w,因为要追加不是覆盖数据。
if (!is_writable ($filename)){die ("文件:".$filename."不可写,请检查其属性后重试!");}
if (!fwrite ($handle,$content)){die ("生成文件”.$filename.”失败!");}
}
$fp = fopen ("_temp3.xml","r");
$content = fread ($fp,filesize ("_temp3.xml"));
$filename = "test/rss.xml";
$handle = fopen ($filename,"a");
if (!is_writable ($filename)){die ("文件:".$filename."不可写,请检查其属性后重试!");}
if (!fwrite ($handle,$content)){die ("生成文件".$filename."失败!");}
fclose ($handle);
die ("成功!");
?>
生成的rss.xml文件竟然:此源包含代码错误。怎么回事呢?这种格式的rss代码错误在哪呢?
_rss.php源代码如下:
<?php
//dim i,link,result;
include_once("../inc/conn.php");
$fp = fopen ("_temp1.xml","r");
$content = fread ($fp,filesize ("_temp1.xml")); //读入打开文件的内容;
$filename = "test/rss.xml"; //拟将rss.xml文件最后生成在test目录下,test目录要具有写权限;
$handle = fopen ($filename,"w"); //fopen,即打开文件,若文件不存在,则自动创建;
if (!is_writable ($filename)){die ("文件:”.$filename.”不可写,请检查其属性后重试!");}
if (!fwrite ($handle,$content)){die ("生成文件".$filename."失败!");}
$i=0;
//$sql = ”SELECT * FROM 'wit_article'”;
$sql="SELECT * FROM wit_article order by art_id desc";
$result = mysql_query($sql,$con);
$k = mysql_num_rows($result);
while( $i<$k )
{
$result1= mysql_query("SELECT * FROM wit_article order by art_id desc limit $i,1");
$a = mysql_fetch_array($result1);
$aid=$a['art_id'];
$cid=$a['art_chaid'];
$i++;
$title = $a['art_title'];
//echo $title;
$link = "http://192.168.1.15/witcms/templates/show.php?cid=$cid&aid=$aid";
//echo $link;
$maintext=$a['art_content'];
$fp = fopen ("_temp2.xml","r");
$content = fread ($fp,filesize ("_temp2.xml"));
$content = str_replace ("{title}",$title,$content); //替换模板变量中的数据;
$content = str_replace ("{link}",$link,$content);
$content = str_replace ("{maintext}",$maintext,$content);
$filename = "test/rss.xml";
$handle = fopen ($filename,"a"); //注意这里是a,不是w,因为要追加不是覆盖数据。
if (!is_writable ($filename)){die ("文件:".$filename."不可写,请检查其属性后重试!");}
if (!fwrite ($handle,$content)){die ("生成文件”.$filename.”失败!");}
}
$fp = fopen ("_temp3.xml","r");
$content = fread ($fp,filesize ("_temp3.xml"));
$filename = "test/rss.xml";
$handle = fopen ($filename,"a");
if (!is_writable ($filename)){die ("文件:".$filename."不可写,请检查其属性后重试!");}
if (!fwrite ($handle,$content)){die ("生成文件".$filename."失败!");}
fclose ($handle);
die ("成功!");
?>
生成的rss.xml文件竟然:此源包含代码错误。怎么回事呢?这种格式的rss代码错误在哪呢?
http://www.xieguang133.com
东莞龙光网络
提供各种平台的解决方案
网站建设与网站改版
百度SEO(自然排名优化,年付)
中国商机发布引擎(软件)
SEO顾问咨询(门户站)
网络推广外包(月付
http://www.xieguang133.com/
posted on 2011-11-18 16:41 xieguang133 阅读(210) 评论(0) 收藏 举报
浙公网安备 33010602011771号