im trying to build a rss feed that will work with my software.

php code

<?php

$t = 15;
$nt = 15000;

$filename3 = "xrssdone.txt";
$content3 = file("xrssdone.txt");

$done = explode("|",$content3[0]);
$num = explode("showtopic=",$_GET["newlink"]);
$nummin = explode("&",$num[1]);
echo $nummin[0];
for ($i=0; $i<$nt; $i++) {
  if ($nummin[0] == $done[$i]) {
    $donebefore = "1";
    break;
  }
}
echo $donebefore;
if ($donebefore != "1") {

$newtitle = $_GET["newtitle"];
$newlink = $_GET["newlink"];
$newmsg = $_GET["newmsg"];
$begin = '<?xml version="1.0" encoding="ISO-8859-1" ?><rss version="2.0"><channel><title>Reptile Planet</title><link>http://herproom.5.forumer.com/index.php?</link><description>New Topics Reptile News</description>';
$newall = "<item><title>";
$newall .= $newtitle;
$newall .= "</title><link>";
$newall .= $newlink;
$newall .= "</link><description>";
$newall .= $newmsg;
$newall .= "</description></item>";
$newall2 = $newall."|||^^*^^|||";
$begin .= $newall;
$end = "</channel></rss>";
$filename = "xrss.xml";
$content = file("xrss.xml");
$filename2 = "xrssmsgs.txt";
$content2 = file("xrssmsgs.txt");
$cont2x = explode("|||^^*^^|||",$content2[0]);
$fp = fopen($filename,"w+");
fwrite($fp,$begin);
for ($i=0; $i<$t; $i++) {
  fwrite($fp,$cont2x[$i]);
}
fwrite($fp,$end);
for ($i=0; $i<$t; $i++) {
  $cont2x[$i] .= "|||^^*^^|||";
}
$fp2 = fopen($filename2,"w+");
fwrite($fp2,$newall2);
for ($i=0; $i<$t; $i++) {
  fwrite($fp2,$cont2x[$i]);
}
for ($i=0; $i<$nt; $i++) {
  if ($done[$i] == "" && $donethat != 1) {
    $done[$i] .= $nummin[0];
    $donethat = 1;
  }
}
for ($i=0; $i<$nt; $i++) {
  $done[$i] .= "|";
  
}
$fp3 = fopen($filename3,"w+");
for ($i=0; $i<$nt; $i++) {
  fwrite($fp3,$done[$i]);
}
}
else {
echo "done";
}

?>

the three other files mentioned in it are hosted in the same root folder and are being written to. im using this javascript

function constrain(str,n){ 
  if(str.length > n){  
    var s = str.substr(0, n);
    var words = s.split(' '); 
    words[words.length-1] = '';
    str = words.join(' ') + lm;
  }
return str;
}
if (location.search.match("showtopic=")) {
var title = document.title;
var link = location.href;
var link2 = link.split("&");
var foruml = "";
var foruml2 = "";
var fixmsg = "";
var yes = 0;
var as3 = new Array();
var is3 = new Array();
var st3 = new Array();
var ss3 = new Array();
var fixmsg4 = new Array();
var fid = document.getElementById('navstrip');
foruml = fid.innerHTML.split("showforum=");
foruml2 = foruml[1].split('">');
for (i=0;i<forums.length;i++) {
if (foruml2[0] == forums[i]) {
yes = 1;
}
}
if (forums[0] == "0") {
yes = 1;
}
if (yes == 1) {
var x=document.getElementsByTagName('DIV');
for(i=0;i<x.length;i++) {
if(x[i].className=='postcolor') {
msg = x[i];
msg2 = msg.innerHTML.split("'");
for(c=0;c<msg2.length;c++) {
fixmsg += msg2[c];
}
as = fixmsg.match(/<a/i);
if (as != "null") {
as2 = fixmsg.split(/a>/i);
for (k=0; k<as2.length; k++) {
as3[k] = as2[k].replace(/<a.*<\//i, lr);
}
as4 = as3.join("");
fixmsg = as4;
}
fixmsg2 = fixmsg.replace(/<br>/ig, "<br />");
fixmsg = fixmsg2;
is = fixmsg.match(/<img/i);
if (is != "null") {
is2 = fixmsg.split(/">/i);
for (k=0; k<is2.length; k++) {
is3[k] = is2[k].replace(/<img.{5,}border="0/i, ir);
}
is4 = is3.join("");
fixmsg = is4;
}
fixmsg2 = fixmsg.split(/<!--endemo-->/i);
for (i=0; i<fixmsg2.length; i++) {
fixmsg3 = fixmsg2[i].replace(ir,"");
fixmsg4[i] = fixmsg3.replace(/<!--emo.*-->/i, "");
}
fixmsg = fixmsg4.join("");
fixmsg2 = fixmsg.split(/<!--emo.{2,5}-->/i);
fixmsg = fixmsg2.join("");
ss = fixmsg.match(/<span/i);
if (ss != "null") {
ss = fixmsg.replace(/;/ig, "<end>");
ss2 = ss.split(/nd>/i);
for (k=0; k<ss2.length; k++) {
ss3[k] = ss2[k].replace(/<span.*<e/i, "");
ss4 = ss3[k].replace(/<\/span>/ig,"");
ss3[k] = ss4;
}
ss4 = ss3.join("");
fixmsg = ss4;
}
fixmsg2 = constrain(fixmsg,1900);
fixmsg = fixmsg2;
document.write("<span style='display:none'><iframe border='0' height='1' width='1' src='"+xrssphp+"?newtitle="+title+"&newlink="+link2[0]+"&newmsg="+fixmsg+"'></iframe></span>");
break;
}
}
}
}

and

<script type="text/javascript">
var forums = new Array();
forums[0] = "25";
var rssphp = "http://free.hostultra.com/~inny/xrss.php";
var lr = "[link removed]";
var ir = "[image removed]";
var lm = "… Click link to view full post.";
</script>

what the hell is wrong?

Recommended Answers

All 7 Replies

> what the hell is wrong?
You should be the one telling us that. I would be surprised if something like this post even got answered.

Just telling that things _don't_ work isn't helpful for anyone. That all being said, you should at least find out if this problem is a PHP one or a Javascript one, post the exact nature of the problem, the expected output and the output you are getting. Plus posting a code with no indentation is an instant repellant.

Try isolating the cause of problem and if it's a PHP one, re-frame the question and post it in the PHP forums.

Sorry Sir!
I get this error

The XML page cannot be displayed 
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. 


--------------------------------------------------------------------------------

XML document must have a top level element. Error processing resource 'http://free.hostultra.com/~inny/xrss.xml'.

im trying to build a rss feed that will work with my software.

php code

<?php

$t = 15;
$nt = 15000;

$filename3 = "xrssdone.txt";
$content3 = file("xrssdone.txt");

$done = explode("|",$content3[0]);
$num = explode("showtopic=",$_GET["newlink"]);
$nummin = explode("&",$num[1]);
echo $nummin[0];
for ($i=0; $i<$nt; $i++) {
  if ($nummin[0] == $done[$i]) {
    $donebefore = "1";
    break;
  }
}
echo $donebefore;
if ($donebefore != "1") {

$newtitle = $_GET["newtitle"];
$newlink = $_GET["newlink"];
$newmsg = $_GET["newmsg"];
$begin = '<?xml version="1.0" encoding="ISO-8859-1" ?><rss version="2.0"><channel><title>Reptile Planet</title><link>http://herproom.5.forumer.com/index.php?</link><description>New Topics Reptile News</description>';
$newall = "<item><title>";
$newall .= $newtitle;
$newall .= "</title><link>";
$newall .= $newlink;
$newall .= "</link><description>";
$newall .= $newmsg;
$newall .= "</description></item>";
$newall2 = $newall."|||^^*^^|||";
$begin .= $newall;
$end = "</channel></rss>";
$filename = "xrss.xml";
$content = file("xrss.xml");
$filename2 = "xrssmsgs.txt";
$content2 = file("xrssmsgs.txt");
$cont2x = explode("|||^^*^^|||",$content2[0]);
$fp = fopen($filename,"w+");
fwrite($fp,$begin);
for ($i=0; $i<$t; $i++) {
  fwrite($fp,$cont2x[$i]);
}
fwrite($fp,$end);
for ($i=0; $i<$t; $i++) {
  $cont2x[$i] .= "|||^^*^^|||";
}
$fp2 = fopen($filename2,"w+");
fwrite($fp2,$newall2);
for ($i=0; $i<$t; $i++) {
  fwrite($fp2,$cont2x[$i]);
}
for ($i=0; $i<$nt; $i++) {
  if ($done[$i] == "" && $donethat != 1) {
    $done[$i] .= $nummin[0];
    $donethat = 1;
  }
}
for ($i=0; $i<$nt; $i++) {
  $done[$i] .= "|";

}
$fp3 = fopen($filename3,"w+");
for ($i=0; $i<$nt; $i++) {
  fwrite($fp3,$done[$i]);
}
}
else {
echo "done";
}

?>

the three other files mentioned in it are hosted in the same root folder and are being written to. im using this javascript

function constrain(str,n){ 
  if(str.length > n){  
    var s = str.substr(0, n);
    var words = s.split(' '); 
    words[words.length-1] = '';
    str = words.join(' ') + lm;
  }
return str;
}
if (location.search.match("showtopic=")) {
var title = document.title;
var link = location.href;
var link2 = link.split("&");
var foruml = "";
var foruml2 = "";
var fixmsg = "";
var yes = 0;
var as3 = new Array();
var is3 = new Array();
var st3 = new Array();
var ss3 = new Array();
var fixmsg4 = new Array();
var fid = document.getElementById('navstrip');
foruml = fid.innerHTML.split("showforum=");
foruml2 = foruml[1].split('">');
for (i=0;i<forums.length;i++) {
if (foruml2[0] == forums[i]) {
yes = 1;
}
}
if (forums[0] == "0") {
yes = 1;
}
if (yes == 1) {
var x=document.getElementsByTagName('DIV');
for(i=0;i<x.length;i++) {
if(x[i].className=='postcolor') {
msg = x[i];
msg2 = msg.innerHTML.split("'");
for(c=0;c<msg2.length;c++) {
fixmsg += msg2[c];
}
as = fixmsg.match(/<a/i);
if (as != "null") {
as2 = fixmsg.split(/a>/i);
for (k=0; k<as2.length; k++) {
as3[k] = as2[k].replace(/<a.*<\//i, lr);
}
as4 = as3.join("");
fixmsg = as4;
}
fixmsg2 = fixmsg.replace(/<br>/ig, "<br />");
fixmsg = fixmsg2;
is = fixmsg.match(/<img/i);
if (is != "null") {
is2 = fixmsg.split(/">/i);
for (k=0; k<is2.length; k++) {
is3[k] = is2[k].replace(/<img.{5,}border="0/i, ir);
}
is4 = is3.join("");
fixmsg = is4;
}
fixmsg2 = fixmsg.split(/<!--endemo-->/i);
for (i=0; i<fixmsg2.length; i++) {
fixmsg3 = fixmsg2[i].replace(ir,"");
fixmsg4[i] = fixmsg3.replace(/<!--emo.*-->/i, "");
}
fixmsg = fixmsg4.join("");
fixmsg2 = fixmsg.split(/<!--emo.{2,5}-->/i);
fixmsg = fixmsg2.join("");
ss = fixmsg.match(/<span/i);
if (ss != "null") {
ss = fixmsg.replace(/;/ig, "<end>");
ss2 = ss.split(/nd>/i);
for (k=0; k<ss2.length; k++) {
ss3[k] = ss2[k].replace(/<span.*<e/i, "");
ss4 = ss3[k].replace(/<\/span>/ig,"");
ss3[k] = ss4;
}
ss4 = ss3.join("");
fixmsg = ss4;
}
fixmsg2 = constrain(fixmsg,1900);
fixmsg = fixmsg2;
document.write("<span style='display:none'><iframe border='0' height='1' width='1' src='"+xrssphp+"?newtitle="+title+"&newlink="+link2[0]+"&newmsg="+fixmsg+"'></iframe></span>");
break;
}
}
}
}

and

<script type="text/javascript">
var forums = new Array();
forums[0] = "25";
var rssphp = "http://free.hostultra.com/~inny/xrss.php";
var lr = "[link removed]";
var ir = "[image removed]";
var lm = "… Click link to view full post.";
</script>

I am constantly getting the following error. Any suggestions please

The XML page cannot be displayed 
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. 


--------------------------------------------------------------------------------

XML document must have a top level element. Error processing resource 'http://free.hostultra.com/~inny/xrss.xml'. 

so much for syntax highlight, i wrapped that last in code & inlinecode

There seems to be some sort of error in your XML file. What happens when you double click the file and try to open it up in a browser? If it doesn't open up, there is some problem for sure. Paste the XML file here wrapped in code tags and properly indented and we will see what can be done.

Ok weird stuff. The first Displays but the second does not! No idea why.

first
http://h1.ripway.com/Inny/bb/472844-rss.xml

<?xml version="1.0" encoding="ISO-8859-1" ?> 
<rss version="2.0">

<channel>

<image>http://i14.photobucket.com/albums/a345/Instar/3e0a6252.gif</image><title>Reptile Planet</title><link>http://herproom.5.forumer.com/index.php?</link><description> Herp News On Reptile Planet</description>

</channel>

</rss>

2nd

http://h1.ripway.com/Inny/rss.xml

<?xml version="1.0" encoding="ISO-8859-1"?> 
<rss version="2.0">
<channel>
<image>http://i14.photobucket.com/albums/a345/Instar/3e0a6252.gif</image><title>Reptile Planet</title><link>http://z6.invisionfree.com/Reptile_Planet/index.php?</link><description> Herp News On Reptile Planet</description>
</channel>
</rss>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.