PDA

View Full Version : Include PHP code in forum...


SAWolf76
Wed 31st Jan '01, 10:10pm
Hello,

I'm trying to include this code in my forum but for some reasion it isn't working?? It works fine on my main page so would u please help me out?



<?php

//======= PRINT =========
function newsitem($title, $url, $description, $image, $imagename) {
echo "<a href='$url' target=_blank>";
echo "<b>$title</b></a> &nbsp;&nbsp; ";

}

//======= PARSE =========
function parse() {
$find=0;
$bbc="http://news.bbc.co.uk";

$fd = fopen("http://news.bbc.co.uk/low/arabic/news/", "r");

while ($buffer = fgets($fd, 4096)) {
if($find==1) {
if(ereg("<IMG border=0",$buffer) ) {
ereg("<IMG border=0 alt=\"(.*)\" src=\"(.*)\"", $buffer, $image);

} elseif(ereg("<A href=",$buffer) ) {
ereg('<A href="(.*)"', $buffer, $head);
$head[2]=ereg_replace('</A><BR>', '', $buffer);
$head[2]=ereg_replace('.*>', '', $head[2]);

} elseif(ereg("<HR>",$buffer)) {
if($image[2]=="")
newsitem($head[2], "$bbc$head[1]", $news, "", "");
else newsitem($head[2], "$bbc$head[1]", $news, "$bbc$image[2]", $image[1]);

$image[2]= $head[2]= $news= "";

} elseif($buffer!="") {
$news= $news . $buffer;
}

}
if( ereg("<BR>الأخبار العالمية",$buffer) ) $find= 1;
if( ($find==1) && ereg("<A CLASS=\"index\"",$buffer) ) break;

}
fclose($fd);
}
// == END PARSE

parse();

?>

Wayne Luke
Wed 31st Jan '01, 11:02pm
How are you trying to include it?

SAWolf76
Thu 1st Feb '01, 7:16am
I've tried both adding it to the header or by using include in the header or templete.

There are no errors as I solved all of that its just not doing the output for some reasion........

PeF
Thu 1st Feb '01, 7:33am
Did you check following in the control panel -> change options?

useadvheader
(Parse header as PHP code)

useadvfooter
(Parse header as PHP code)

Wayne Luke
Thu 1st Feb '01, 10:25am
You also need to set all of that equal to the $header or $footer.

SAWolf76
Thu 1st Feb '01, 12:01pm
Yes Pef I did as I'm already running two php scripts there.

Wluke I'm not sure what you mean??

Here's what I did.....

In the header:
1. I copyed the whole code in there where I need it with out <?php ?> and with changeing echo to $header.=

This don't not work as I get nothing out and the header looks ok with no errors its as if its not there.

2. I then tryed to use include("/home/arabiano/public_html/bbc.php3"); and I got some trash so I changed the echo to $header.= and no more trash its as if the code isn't there.

oh and when its echo it works but I get it all mixed up in the code and it looks like trash.

In the templete:

I tryed to use include("/home/arabiano/public_html/bbc.php3"); and it didn't do any thing neatgir if I'm using echo or $header.= its as if the code isn't there.....

Thank you all for your responces.......

SAWolf76
Fri 2nd Feb '01, 2:11pm
Sorry the thread went so low I wanted to move it up.

PeF
Fri 2nd Feb '01, 4:02pm
Instead of /home/arabiano/public_html/bbc.php3 try http://URL to the file. It helped me once.

SAWolf76
Fri 2nd Feb '01, 4:32pm
Thanks PeF but didn't work........

I think this might help some of you.......

The following is a picture of the forum in operation and the script I'm using is supposed to get the news from the BBC website in Arabic and scroll it in one of the boxes you see........

http://www.arabianoasis.net/temp/site.jpg

The second picture is of the forum when the script is using echo insted of $header where the news is shown but not in place insted on top and messing the whole site......

http://www.arabianoasis.net/temp/siteerror.jpg

Thank you all for your help.......