Agent Moose
12-20-2007, 04:24 PM
I have created a code taht only works on my XAMMP Program, nothing else. I have tried my brothers host that uses PHP, but I get this error:
Fatal error: Cannot redeclare link() in /home/mosthigh/public_html/codeindex2.php on line 4
Here is my code:
<?
echo "<table width='100%' style='font-weight:bold'><tr><td width='33%'>Code</td><td width='33%'>Started By</td><td width='33%'>Views</td></tr></table>";
function link($val){
$as=$val->getElementsByTagName('a');
foreach($as as $a){
return "<a href='".$a->getAttribute('href')."'>".$a->nodeValue."</a>";
}}
$c=1;
for($i=0;$i<$c;$i++){
$doc=new DOMDocument();
@$doc->loadHTMLFile("http://smcodes.smfforfree3.com/index.php/board,8.".($i*15).".html");
$tables=$doc->getElementsByTagName('table');
if($i==0){
$ltds=$doc->getElementsByTagName('td');
foreach($ltds as $ltd){
if($ltd->getAttribute('class')=="middletext" && eregi('go down',$ltd->nodeValue)){
$las=$ltd->getElementsByTagName('a');
foreach($las as $la){
if($la->getAttribute('class')=="navPages"){
$c++;
}}}}}
foreach($tables as $table){
if($table->getAttribute('width')=="100%" && $table->getAttribute('border')=="0" && $table->getAttribute('cellspacing')=="1" && $table->getAttribute('cellpadding')=="4"){
$trs=$table->getElementsByTagName('tr');
foreach($trs as $tr){
$topic=$tr->childNodes->item(4);
$started=$tr->childNodes->item(6);
$view=$tr->childNodes->item(10);
if($topic->nodeValue == "" || $started->nodeValue == "" || $view->nodeValue == ""){
}else if(eregi("When Using My Codes",$topic->nodeValue)){
}else if($topic->nodeValue == "Started by" || $started->nodeValue == "Replies" || $view->nodeValue == "Last post"){
}else{
echo "<table width='100%'><tr><td width='33%'>".link($topic)."</td><td width='33%'>".link($started)."</td><td width='33%'>".$view->nodeValue."</td></table>";
}}}}}
?>
Fatal error: Cannot redeclare link() in /home/mosthigh/public_html/codeindex2.php on line 4
Here is my code:
<?
echo "<table width='100%' style='font-weight:bold'><tr><td width='33%'>Code</td><td width='33%'>Started By</td><td width='33%'>Views</td></tr></table>";
function link($val){
$as=$val->getElementsByTagName('a');
foreach($as as $a){
return "<a href='".$a->getAttribute('href')."'>".$a->nodeValue."</a>";
}}
$c=1;
for($i=0;$i<$c;$i++){
$doc=new DOMDocument();
@$doc->loadHTMLFile("http://smcodes.smfforfree3.com/index.php/board,8.".($i*15).".html");
$tables=$doc->getElementsByTagName('table');
if($i==0){
$ltds=$doc->getElementsByTagName('td');
foreach($ltds as $ltd){
if($ltd->getAttribute('class')=="middletext" && eregi('go down',$ltd->nodeValue)){
$las=$ltd->getElementsByTagName('a');
foreach($las as $la){
if($la->getAttribute('class')=="navPages"){
$c++;
}}}}}
foreach($tables as $table){
if($table->getAttribute('width')=="100%" && $table->getAttribute('border')=="0" && $table->getAttribute('cellspacing')=="1" && $table->getAttribute('cellpadding')=="4"){
$trs=$table->getElementsByTagName('tr');
foreach($trs as $tr){
$topic=$tr->childNodes->item(4);
$started=$tr->childNodes->item(6);
$view=$tr->childNodes->item(10);
if($topic->nodeValue == "" || $started->nodeValue == "" || $view->nodeValue == ""){
}else if(eregi("When Using My Codes",$topic->nodeValue)){
}else if($topic->nodeValue == "Started by" || $started->nodeValue == "Replies" || $view->nodeValue == "Last post"){
}else{
echo "<table width='100%'><tr><td width='33%'>".link($topic)."</td><td width='33%'>".link($started)."</td><td width='33%'>".$view->nodeValue."</td></table>";
}}}}}
?>