zamboo Posted August 7, 2008 Share Posted August 7, 2008 Hello guys, I've googled all over the web and i'm just about to give up. I'm attempting to have a random ad displayer display text ads within a box inside a php file. The issue is, no matter what I do it will not display the file. echo "\n\n<div style='margin-top: 10px; margin-bottom: 10px;'><table border=0 width=500>"; echo "\n<tr>"; echo "\n<td width='150' align='center'>"; echo "\n$imagelink</td>"; echo "\n<td align='left'>"; echo "\n$seolink<br>"; echo "\nPosted by: $authorlink<br><br>"; echo "\n<div class='desc'>"; echo "\nVideo duration: $duration seconds<br>"; if(!strpos($rss,"gdata.youtube.com/feeds/api/users")) echo "\nGlobal video hits: $views"; echo "\n</div><br>"; echo "\n$description<br><br>"; echo "\nRelated: $keywordslinked"; echo "\n</td>"; echo "\n</tr>"; echo "\n<tr><td colspan=2><div style='margin-top: 10px; margin-bottom: 10px;'>"; echo "\n \n"; >>>>>>>>>>>>>>>>>>>>((( IM TRYING TO PUT THE CODE IN HERE )))) if(($i<$total)&&($i<$maxreturned)) echo ""; echo "</div></td></tr>"; echo "\n</table></div>\n"; $i++; } I tried a $textad = include("textads.php"); then above where you see ((( IM TRYING TO PUT THE CODE IN HERE ))) i put echo "$textad"; but it will still not display, it displays a "1" for some reason. I've tried simple include("textads.php"); also, and nothing even shows up. The textad.php file simply runs a code and grabs random ad from a text file: <?php $fcontents = join ('', file ('textads.txt')); $s_con = split("~",$fcontents); $banner_no = rand(0,(count($s_con)-1)); echo $s_con[$banner_no]; ?> Any input would be appreciated. Thank you Link to comment https://forums.phpfreaks.com/topic/118673-cannot-get-php-to-show-within-another-php-fileplease-help/ Share on other sites More sharing options...
wildteen88 Posted August 7, 2008 Share Posted August 7, 2008 Hello guys, I've googled all over the web and i'm just about to give up. I'm attempting to have a random ad displayer display text ads within a box inside a php file. The issue is, no matter what I do it will not display the file. echo "\n\n<div style='margin-top: 10px; margin-bottom: 10px;'><table border=0 width=500>"; echo "\n<tr>"; echo "\n<td width='150' align='center'>"; echo "\n$imagelink</td>"; echo "\n<td align='left'>"; echo "\n$seolink<br>"; echo "\nPosted by: $authorlink<br><br>"; echo "\n<div class='desc'>"; echo "\nVideo duration: $duration seconds<br>"; if(!strpos($rss,"gdata.youtube.com/feeds/api/users")) echo "\nGlobal video hits: $views"; echo "\n</div><br>"; echo "\n$description<br><br>"; echo "\nRelated: $keywordslinked"; echo "\n</td>"; echo "\n</tr>"; echo "\n<tr><td colspan=2><div style='margin-top: 10px; margin-bottom: 10px;'>"; echo "\n \n"; >>>>>>>>>>>>>>>>>>>>((( IM TRYING TO PUT THE CODE IN HERE )))) if(($i<$total)&&($i<$maxreturned)) echo ""; echo "</div></td></tr>"; echo "\n</table></div>\n"; $i++; } With that code you have missing opening brace ({), Secondly include doesn't return anything so you can't assign it to a variable. Link to comment https://forums.phpfreaks.com/topic/118673-cannot-get-php-to-show-within-another-php-fileplease-help/#findComment-610988 Share on other sites More sharing options...
zamboo Posted August 7, 2008 Author Share Posted August 7, 2008 Sorry let me paste the entire code, i thoguth i did but it was just part of it: <?PHP function getdata($rss,$extra,$whatpage) { include "global.php"; chdir("magpie"); require_once("rss_fetch.inc"); $rss2 = fetch_rss($rss); $total=sizeof($rss2->items); $i=1; if($extra) { echo $extra; echo '<div>'; include "config.php"; include "mainads.php"; echo '</div>'; } else { echo '<div style="padding-left: 14px">'; include "config.php"; include "mainads.php"; echo '</div>'; } if($extra) echo "<br><br><b>Other videos by this author:</b><br><br>"; //print_r($rss2); $channel = $rss2->channel; $realmax = $channel['opensearch']['totalresults']; foreach ($rss2->items as $item) { if($i>$maxreturned) break; //print_r($item); $watchlink = $item['link']; $embedlink = str_replace("watch?v=","v/",$watchlink); $author = $item['author_name']; $authorprofile = $item['author_uri']; $authorvideos = "http://www.youtube.com/rss/user/$author/videos.rss"; $authorlink = "<a href='video-poster/" . strtolower($author) . ".html'>$author</a>"; $tempdata = $item['title']; $content = $item['atom_content']; $id = str_replace("http://www.youtube.com/watch?v=","",$watchlink); $thumb = "http://img.youtube.com/vi/$id/2.jpg"; $next = 0; foreach(split("\n",$content) as $tmp) { if($next) { $views = $tmp; break; } if(strpos($tmp,"Views:")) { $next = 1; } } //print_r($content); $views = str_replace("</div>","",$views); $data = split("/>",$tempdata); //print_r($data); for($j=0;$j<sizeof($data);$j++) { if(strpos($data[$j],"media:description")) $descid = $j; if(strpos($data[$j],"media:keywords")) $keyid = $j; if(strpos($data[$j],"yt:duration")) $duraid = $j; if(strpos($data[$j],"media:title")) $titleid = $j; } $title = $data[$titleid]; $title = str_replace("<media:title ","",$title); $title = substr($title,0,strlen($title)/2); if(strpos($title,"gdata")||(strlen($title)>100)) continue; for($x=0;$x<sizeof($bannedwords);$x++) { if(strpos(strtolower($title),strtolower($bannedwords[$x]))) { $badtitle=1; break; } } if($badtitle) continue; $description = $data[$descid]; $description = str_replace("<media:description type=\"plain\">","",$description); $description = str_replace("<media:description ","",$description); $description = str_replace("\n\n\n\n","\n",$description); $description = str_replace("\n\n\n","\n",$description); $description = str_replace("\n\n","\n",$description); $description = nl2br($description); if(strlen($description)>400) continue; if(findbadwords($description)==1) continue; $description = wordwrap($description, 20, " ", true); $keywords = $data[$keyid]; $keywords = str_replace("<media:keywords >","",$keywords); $keywords = str_replace("<media:keywords ","",$keywords); $duration = $data[$duraid]; $duration = str_replace("<yt:duration seconds=\"","",$duration); $duration = str_replace("<yt:duration ","",$duration); $duration = str_replace("\">","",$duration); $seotitle = str_replace("/","-",strtolower($title)); $seotitle = str_replace("'","",$seotitle); $seotitle = str_replace("\"","",$seotitle); $seotitle = str_replace("?","",$seotitle); $seotitle = str_replace("!","",$seotitle); $seotitle = str_replace("#"," ",$seotitle); $seotitle = str_replace("("," ",$seotitle); $seotitle = str_replace(")"," ",$seotitle); $seotitle = str_replace("["," ",$seotitle); $seotitle = str_replace("]"," ",$seotitle); $seotitle = str_replace("?"," ",$seotitle); $seotitle = trim($seotitle); $seotitle = str_replace(" ","-",strtolower($seotitle)); $seotitle = str_replace("---","-",$seotitle); $seotitle = str_replace("--","-",$seotitle); $seolink = "<a href='watch-video/$id/".$author."/$seotitle.html'>$title</a>"; $title2=addslashes($title); $imagelink = "<a href='watch-video/$id/".$author."/$seotitle.html'><img src='$thumb' width=130 height=97 class='border' style='border-bottom: 2px solid #CC0000; border-top: 2px solid #CC0000' alt='$title2' title='$title2'></a>"; $linkkeywords=array(); foreach(split(",",$keywords) as $tmpkeyword) { $tmpkeyword = trim($tmpkeyword); $tmpkeyword = str_replace("/","",strtolower($tmpkeyword)); $tmpkeyword = str_replace("'","",$tmpkeyword); $tmpkeyword = str_replace("\"","",$tmpkeyword); $tmpkeyword = str_replace("?","",$tmpkeyword); $tmpkeyword = str_replace("!","",$tmpkeyword); $tmpkeyword = str_replace("#","",$tmpkeyword); $tmpkeyword = str_replace("(","",$tmpkeyword); $tmpkeyword = str_replace(")","",$tmpkeyword); $tmpkeyword = str_replace("[","",$tmpkeyword); $tmpkeyword = str_replace("]","",$tmpkeyword); $tmpkeyword = str_replace("?","",$tmpkeyword); if($tmpkeyword&&!in_array($tmpkeyword,$bannedwords)) $linkkeywords[] = "<a href='video-theme/" . strtolower($tmpkeyword) . ".html'>$tmpkeyword</a>"; } $keywordslinked = implode(", ",$linkkeywords); if(!$keywordslinked) $keywordslinked = "N/A"; echo "\n\n<div style='margin-top: 10px; margin-bottom: 10px;'><table border=0 width=500>"; echo "\n<tr>"; echo "\n<td width='150' align='center'>"; echo "\n$imagelink</td>"; echo "\n<td align='left'>"; echo "\n$seolink<br>"; echo "\nPosted by: $authorlink<br><br>"; echo "\n<div class='desc'>"; echo "\nVideo duration: $duration seconds<br>"; if(!strpos($rss,"gdata.youtube.com/feeds/api/users")) echo "\nGlobal video hits: $views"; echo "\n</div><br>"; echo "\n$description<br><br>"; echo "\nRelated: $keywordslinked"; echo "\n</td>"; echo "\n</tr>"; echo "\n<tr><td colspan=2><div style='margin-top: 10px; margin-bottom: 10px;'>"; echo "\n \n"; >>>>>>THIS IS WHERE I WANT THE CODE TO DISPLAY<<<<<<<< if(($i<$total)&&($i<$maxreturned)) echo ""; echo "</div></td></tr>"; echo "\n</table></div>\n"; $i++; } chdir(".."); if(strstr($rss,"http://gdata.youtube.com/feeds/videos?vq=")) { if($maxreturned>999) $maxreturned = 999; if($totalmax>999) $totalmax=999; if($realmax<999) $totalmax=$realmax; if($totalmax<$maxreturned) $totalmax=$maxreturned; $totalpages = ceil($totalmax/$maxreturned); $looppage = 1; $linktheme = str_replace("http://gdata.youtube.com/feeds/videos?vq=","",$rss); $wherestop = strpos($linktheme,"&"); $linktheme2 = substr($linktheme,0,$wherestop); include_once "config.php"; $themelinkage = 'http://'.$_SERVER['HTTP_HOST'].'/'; if($folder) { if($folder[strlen($folder)-1]=='/') $themelinkage.= $folder; else $themelinkage.= $folder . '/'; } $themelinkage.= "video-theme/"; echo "<div align='left'><table border=0 width='90%' style='margin: 10px; background: #FFFFFF; border: 1px dashed #444444'><tr><td>Page: "; while($looppage<=$totalpages) { echo "<span class='page'><a href='" . $themelinkage . "$looppage/".$linktheme2.".html'>$looppage</a></span> "; $looppage++; } echo "</td></tr></table></div><br>"; } } function findbadwords($string) { include "global.php"; $found = 0; $string = strtolower($string); $string = str_replace("<br>","\n",$string); $string = str_replace("<br/>","\n",$string); $string = str_replace("<br />","\n",$string); for($x=0;$x<sizeof($bannedwords);$x++) { if(strpos($string,strtolower($bannedwords[$x]))) { $found=1; break; } foreach(split("\n",$string) as $line) { if(strpos($line,strtolower($bannedwords[$x]))) { $found = 1; break; } } if($found) break; } return $found; } ?> Link to comment https://forums.phpfreaks.com/topic/118673-cannot-get-php-to-show-within-another-php-fileplease-help/#findComment-611018 Share on other sites More sharing options...
Stooney Posted August 7, 2008 Share Posted August 7, 2008 I would suggest breaking it all up into pieces and testing each piece separately. Find out where things start going wrong. I doubt anyone here will sift through all of your code for you. Link to comment https://forums.phpfreaks.com/topic/118673-cannot-get-php-to-show-within-another-php-fileplease-help/#findComment-611020 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.