Current location: Hot Scripts Forums » Programming Languages » PHP » HELP HS random_banner - works great, but not from my forum?? :-(


HELP HS random_banner - works great, but not from my forum?? :-(

Reply
  #1 (permalink)  
Old 09-04-06, 11:16 AM
Sarchi Sarchi is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Angry HELP HS random_banner - works great, but not from my forum?? :-(

Please help, this is driving me nuts. I downloaded the hotscript random_banner (PHP->Randomizers).

You can see the script works perfectly, execute it either of two ways:
http://www.triumph675.net/phpBB2/tem...er/webpage.php
http://www.triumph675.net/phpBB2/tem..._advertise.php

Then check my forum http://www.triumph675.net/phpBB2/

At the end of my overall_header.tpl file, I have the <img src> tag and no matter what I try it doesn't execute the script, just displays a red X. The code is:
<a href="about:blank"><img src="templates/subSilver/random_advertise.php" border="0" alt="0" vspace="1" /></a>

p.s. my logo image uses a similar (simpler) php script in the same header file and the code works fine, as you can see. (For ads I needed one that can use a separate href for each banner......)

TIA

Last edited by Sarchi; 09-04-06 at 11:19 AM.
Reply With Quote
  #2 (permalink)  
Old 09-04-06, 11:22 AM
Sarchi Sarchi is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Here's the script code, FWIW. The only changes I made were to eaqualize the weightings and change the URL's, href and alt tags.
PHP Code:

  <?php

    
/*
    ###########################################
    Random Advertisement
    This script is free as long as this message
    remains as it is.
    Copyright: Scriptsez.net
    For more free scripts visit: [url]http://www.scriptsez.net[/url]
    ###########################################
    Notes: shows a random banner on the webpage, using weighting system.
    */
    ## Configure this acc. to your needs ##
    
    
$Ad[0] = '<a href="http://www.motoworldonline.com" id="link1"><img src="images/MW1.gif" width="468" height="60" alt="Visit our Sponsor" border="0" id="link_1" /></a>';
    
$Ad[1] = '<a href="http://www.oncycles.com" id="link2"><img src="images/Oncycles.gif" width="468" height="60" alt="Visit our Sponsor" border="0" id="link_2" /></a>';
    
$Ad[2] = '<a href="http://www.motoworldonline.com" id="link3"><img src="images/MW1.gif" width="468" height="60" alt="Visit our Sponsor" border="0" id="link_3" /></a>';
    
$Ad[3] = '<a href="http://www.oncycles.com" id="link4"><img src="images/Oncycles.gif" width="468" height="60" alt="Visit our Sponsor" border="0" id="link_4" /></a>';
    
$Ad[4] = '<a href="http://www.motoworldonline.com" id="link5"><img src="images/MW1.gif" width="468" height="60" alt="Visit our Sponsor" border="0" id="link_5" /></a>';
    
$Ad[5] = '<a href="http://www.oncycles.com" id="link6"><img src="images/Oncycles.gif" width="468" height="60" alt="Visit our Sponsor" border="0" id="link_6" /></a>';
    
    
$Weight[0]=1;
    
$Weight[1]=1;
    
$Weight[2]=1;
    
$Weight[3]=1;
    
$Weight[4]=1;
    
$Weight[5]=1;
    
$sum =0;
    for(
$i=0;$i<count($Weight);$i++)
        
$sum+=$Weight[$i];
    
$ShowAd rand(0$sum 1);
    for(
$i=0;$i<count($Weight);$i++)
    {
        if(
$ShowAd<=$Weight[$i])
        {
            
$ShowAd=$i;
            break;
        }
        else
            
$ShowAd-=$Weight[$i];
    }
    echo 
$Ad[$ShowAd];
    
?>

Last edited by nico_swd; 09-04-06 at 12:21 PM.
Reply With Quote
  #3 (permalink)  
Old 09-04-06, 11:44 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Your <a href... code has this tag </html> immediately after it. I recommend removing it.
Code:
<a href="about:blank"><img src="templates/subSilver/random_advertise.php" border="0" alt="0" vspace="1" /></a></html>
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #4 (permalink)  
Old 09-04-06, 12:27 PM
Sarchi Sarchi is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
I tried that (again) but it makes no difference.

I've tried removing the <a> tag, removing just the href, moving the code to a different part of the page, etc. etc. Same result always.
Reply With Quote
  #5 (permalink)  
Old 09-04-06, 02:02 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Upon further review, the random_advertise.php code echos it's own <a href... link. You cannot put this into a <img src= tag.

You must include this into your PHP source code, something like this -
PHP Code:

include "templates/subSilver/random_advertise.php"
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #6 (permalink)  
Old 09-04-06, 07:02 PM
Sarchi Sarchi is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, that makes sense....

But, I can't find the right html syntax to call the php script. I checked W3 Schools and tried 'include', etc but nothing's working. Sorry for all the ?'s but I obviously need some hand-holding.
Reply With Quote
  #7 (permalink)  
Old 09-04-06, 09:48 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Since you mention html, I will assume the existing code is straight html within a php file. If so, the following should work -
PHP Code:

<?php include "templates/subSilver/random_advertise.php"?>

If not, post your existing code to get more specific help.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #8 (permalink)  
Old 09-05-06, 04:19 PM
Sarchi Sarchi is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
That didn't work. Here's the code for my overall_header.tpl file. Thanks again..
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="{S_CONTENT_DIRECTION}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset={S_CONTENT_ENCODING}">
<meta http-equiv="Content-Style-Type" content="text/css">
{META}
{NAV_LINKS}
<title>{SITENAME} :: {PAGE_TITLE}</title>
<!-- link rel="stylesheet" href="templates/subSilver/{T_HEAD_STYLESHEET}" type="text/css" -->
<style type="text/css">
<!--
/*
  The original subSilver Theme for phpBB version 2+
  Created by subBlue design
  http://www.subBlue.com

  NOTE: These CSS definitions are stored within the main page body so that you can use the phpBB2
  theme administration centre. When you have finalised your style you could cut the final CSS code
  and place it in an external file, deleting this section to save bandwidth.
*/

/* General page style. The scroll bar colours only visible in IE5.5+ */
body { 
	background-color: {T_BODY_BGCOLOR};
	scrollbar-face-color: {T_TR_COLOR2};
	scrollbar-highlight-color: {T_TD_COLOR2};
	scrollbar-shadow-color: {T_TR_COLOR2};
	scrollbar-3dlight-color: {T_TR_COLOR3};
	scrollbar-arrow-color:  {T_BODY_LINK};
	scrollbar-track-color: {T_TR_COLOR1};
	scrollbar-darkshadow-color: {T_TH_COLOR1};
}

/* General font families for common tags */
font,th,td,p { font-family: {T_FONTFACE1} }
a:link,a:active,a:visited { color : {T_BODY_LINK}; }
a:hover		{ text-decoration: underline; color : {T_BODY_HLINK}; }
hr	{ height: 0px; border: solid {T_TR_COLOR3} 0px; border-top-width: 1px;}

/* This is the border line & background colour round the entire page */
.bodyline	{ background-color: {T_TD_COLOR2}; border: 1px {T_TH_COLOR1} solid; }

/* This is the outline round the main forum tables */
.forumline	{ background-color: {T_TD_COLOR2}; border: 2px {T_TH_COLOR2} solid; }

/* Main table cell colours and backgrounds */
td.row1	{ background-color: {T_TR_COLOR1}; }
td.row2	{ background-color: {T_TR_COLOR2}; }
td.row3	{ background-color: {T_TR_COLOR3}; }

/*
  This is for the table cell above the Topics, Post & Last posts on the index.php page
  By default this is the fading out gradiated silver background.
  However, you could replace this with a bitmap specific for each forum
*/
td.rowpic {
		background-color: {T_TD_COLOR2};
		background-image: url(templates/subSilver/images/{T_TH_CLASS3});
		background-repeat: repeat-y;
}

/* Header cells - the blue and silver gradient backgrounds */
th	{
	color: {T_FONTCOLOR3}; font-size: {T_FONTSIZE2}px; font-weight : bold; 
	background-color: {T_BODY_LINK}; height: 25px;
	background-image: url(templates/subSilver/images/{T_TH_CLASS2});
}

td.cat,td.catHead,td.catSides,td.catLeft,td.catRight,td.catBottom {
			background-image: url(templates/subSilver/images/{T_TH_CLASS1});
			background-color:{T_TR_COLOR3}; border: {T_TH_COLOR3}; border-style: solid; height: 28px;
}

/*
  Setting additional nice inner borders for the main table cells.
  The names indicate which sides the border will be on.
  Don't worry if you don't understand this, just ignore it :-)
*/
td.cat,td.catHead,td.catBottom {
	height: 29px;
	border-width: 0px 0px 0px 0px;
}
th.thHead,th.thSides,th.thTop,th.thLeft,th.thRight,th.thBottom,th.thCornerL,th.thCornerR {
	font-weight: bold; border: {T_TD_COLOR2}; border-style: solid; height: 28px;
}
td.row3Right,td.spaceRow {
	background-color: {T_TR_COLOR3}; border: {T_TH_COLOR3}; border-style: solid;
}

th.thHead,td.catHead { font-size: {T_FONTSIZE3}px; border-width: 1px 1px 0px 1px; }
th.thSides,td.catSides,td.spaceRow	 { border-width: 0px 1px 0px 1px; }
th.thRight,td.catRight,td.row3Right	 { border-width: 0px 1px 0px 0px; }
th.thLeft,td.catLeft	  { border-width: 0px 0px 0px 1px; }
th.thBottom,td.catBottom  { border-width: 0px 1px 1px 1px; }
th.thTop	 { border-width: 1px 0px 0px 0px; }
th.thCornerL { border-width: 1px 0px 0px 1px; }
th.thCornerR { border-width: 1px 1px 0px 0px; }

/* The largest text used in the index page title and toptic title etc. */
.maintitle	{
	font-weight: bold; font-size: 22px; font-family: "{T_FONTFACE2}",{T_FONTFACE1};
	text-decoration: none; line-height : 120%; color : {T_BODY_TEXT};
}

/* General text */
.gen { font-size : {T_FONTSIZE3}px; }
.genmed { font-size : {T_FONTSIZE2}px; }
.gensmall { font-size : {T_FONTSIZE1}px; }
.gen,.genmed,.gensmall { color : {T_BODY_TEXT}; }
a.gen,a.genmed,a.gensmall { color: {T_BODY_LINK}; text-decoration: none; }
a.gen:hover,a.genmed:hover,a.gensmall:hover	{ color: {T_BODY_HLINK}; text-decoration: underline; }

/* The register, login, search etc links at the top of the page */
.mainmenu		{ font-size : {T_FONTSIZE2}px; color : {T_BODY_TEXT} }
a.mainmenu		{ text-decoration: none; color : {T_BODY_LINK};  }
a.mainmenu:hover{ text-decoration: underline; color : {T_BODY_HLINK}; }

/* Forum category titles */
.cattitle		{ font-weight: bold; font-size: {T_FONTSIZE3}px ; letter-spacing: 1px; color : {T_BODY_LINK}}
a.cattitle		{ text-decoration: none; color : {T_BODY_LINK}; }
a.cattitle:hover{ text-decoration: underline; }

/* Forum title: Text and link to the forums used in: index.php */
.forumlink		{ font-weight: bold; font-size: {T_FONTSIZE3}px; color : {T_BODY_LINK}; }
a.forumlink 	{ text-decoration: none; color : {T_BODY_LINK}; }
a.forumlink:hover{ text-decoration: underline; color : {T_BODY_HLINK}; }

/* Used for the navigation text, (Page 1,2,3 etc) and the navigation bar when in a forum */
.nav			{ font-weight: bold; font-size: {T_FONTSIZE2}px; color : {T_BODY_TEXT};}
a.nav			{ text-decoration: none; color : {T_BODY_LINK}; }
a.nav:hover		{ text-decoration: underline; }

/* titles for the topics: could specify viewed link colour too */
.topictitle,h1,h2	{ font-weight: bold; font-size: {T_FONTSIZE2}px; color : {T_BODY_TEXT}; }
a.topictitle:link   { text-decoration: none; color : {T_BODY_LINK}; }
a.topictitle:visited { text-decoration: none; color : {T_BODY_VLINK}; }
a.topictitle:hover	{ text-decoration: underline; color : {T_BODY_HLINK}; }

/* Name of poster in viewmsg.php and viewtopic.php and other places */
.name			{ font-size : {T_FONTSIZE2}px; color : {T_BODY_TEXT};}

/* Location, number of posts, post date etc */
.postdetails		{ font-size : {T_FONTSIZE1}px; color : {T_BODY_TEXT}; }

/* The content of the posts (body of text) */
.postbody { font-size : {T_FONTSIZE3}px; line-height: 18px}
a.postlink:link	{ text-decoration: none; color : {T_BODY_LINK} }
a.postlink:visited { text-decoration: none; color : {T_BODY_VLINK}; }
a.postlink:hover { text-decoration: underline; color : {T_BODY_HLINK}}

/* Quote & Code blocks */
.code { 
	font-family: {T_FONTFACE3}; font-size: {T_FONTSIZE2}px; color: {T_FONTCOLOR2};
	background-color: {T_TD_COLOR1}; border: {T_TR_COLOR3}; border-style: solid;
	border-left-width: 1px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px
}

.quote {
	font-family: {T_FONTFACE1}; font-size: {T_FONTSIZE2}px; color: {T_FONTCOLOR1}; line-height: 125%;
	background-color: {T_TD_COLOR1}; border: {T_TR_COLOR3}; border-style: solid;
	border-left-width: 1px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px
}

/* Copyright and bottom info */
.copyright		{ font-size: {T_FONTSIZE1}px; font-family: {T_FONTFACE1}; color: {T_FONTCOLOR1}; letter-spacing: -1px;}
a.copyright		{ color: {T_FONTCOLOR1}; text-decoration: none;}
a.copyright:hover { color: {T_BODY_TEXT}; text-decoration: underline;}

/* Form elements */
input,textarea, select {
	color : {T_BODY_TEXT};
	font: normal {T_FONTSIZE2}px {T_FONTFACE1};
	border-color : {T_BODY_TEXT};
}

/* The text input fields background colour */
input.post, textarea.post, select {
	background-color : {T_TD_COLOR2};
}

input { text-indent : 2px; }

/* The buttons used for bbCode styling in message post */
input.button {
	background-color : {T_TR_COLOR1};
	color : {T_BODY_TEXT};
	font-size: {T_FONTSIZE2}px; font-family: {T_FONTFACE1};
}

/* The main submit button option */
input.mainoption {
	background-color : {T_TD_COLOR1};
	font-weight : bold;
}

/* None-bold submit button */
input.liteoption {
	background-color : {T_TD_COLOR1};
	font-weight : normal;
}

/* This is the line in the posting page which shows the rollover
  help line. This is actually a text box, but if set to be the same
  colour as the background no one will know ;)
*/
.helpline { background-color: {T_TR_COLOR2}; border-style: none; }

/* Import the fancy styles for IE only (NS4.x doesn't use the @import function) */
@import url("templates/subSilver/formIE.css"); 
-->
</style>
<!-- BEGIN switch_enable_pm_popup -->
<script language="Javascript" type="text/javascript">
<!--
	if ( {PRIVATE_MESSAGE_NEW_FLAG} )
	{
		window.open('{U_PRIVATEMSGS_POPUP}', '_phpbbprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');;
	}
//-->
</script>
<!-- END switch_enable_pm_popup -->
</head>
<body bgcolor="{T_BODY_BGCOLOR}" text="{T_BODY_TEXT}" link="{T_BODY_LINK}" vlink="{T_BODY_VLINK}">

<a name="top"></a>

<table width="100%" cellspacing="0" cellpadding="10" border="0" align="center"> 
	<tr> 
		<td class="bodyline"><table width="100%" cellspacing="0" cellpadding="0" border="0">
			<tr> 
				<td><a href="http://www.triumph675.net/main.htm"><img src="templates/subSilver/images/random_logo/logo.php" border="0" alt="Go to Triumph675.Net Home Page" vspace="1" /></a></td>
				<td align="center" width="100%" valign="middle"><span class="maintitle">{SITENAME}</span><br /><span class="gen">{SITE_DESCRIPTION}<br />&nbsp; </span> 
				<table cellspacing="0" cellpadding="2" border="0">
					<tr> 
						<td align="center" valign="top" nowrap="nowrap"><span class="mainmenu">&nbsp;<a href="http://www.triumph675.net/phpBB2" class="mainmenu"><img src="templates/subSilver/images/icon_mini_home.gif" width="12" height="13" border="0" alt="Forum Index" hspace="3" />{L_HOME}</a></span><span class="mainmenu">&nbsp;<a href="http://www.triumph675.net/photos" class="mainmenu"><img src="templates/subSilver/images/icon_mini_photo.gif" width="12" height="13" border="0" alt="Triumph675.net/photos" hspace="3" />{L_PHOTOS}</a></span><span class="mainmenu">&nbsp; &nbsp;<a href="http://www.triumph675.net/links" class="mainmenu"><img src="templates/subSilver/images/icon_mini_groups.gif" width="12" height="13" border="0" alt="Links Directory" hspace="3" />{L_LINKS}</a>&nbsp; &nbsp;<a href="{U_FAQ}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_faq.gif" width="12" height="13" border="0" alt="Forum FAQ (Help)" hspace="3" />{L_FAQ}</a></span><span class="mainmenu">&nbsp; &nbsp;<br /><br/><a href="http://www.triumph675.net/phpBB2/search.php?search_id=newposts" class="mainmenu"><img src="templates/subSilver/images/icon_mini_members.gif" width="12" height="13" border="0" alt="New posts since your last visit" hspace="3" />New Posts  </a><a href="{U_SEARCH}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_search.gif" width="12" height="13" border="0" alt="Search the Forums" hspace="3" />{L_SEARCH}</a>&nbsp; &nbsp;<a href="{U_MEMBERLIST}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_members.gif" width="12" height="13" border="0" alt="View the Member list" hspace="3" />{L_MEMBERLIST}</a>&nbsp; &nbsp;<a href="{U_GROUP_CP}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_groups.gif" width="12" height="13" border="0" alt="{L_USERGROUPS}" hspace="3" />{L_USERGROUPS}</a><br /></span></td></tr>	<tr>	<td><span class="mainmenu">&nbsp;<a href="{U_PROFILE}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_profile.gif" width="12" height="13" border="0" alt="Update your Profile" hspace="3" />{L_PROFILE}</a>&nbsp; &nbsp;<a href="{U_PRIVATEMSGS}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_message.gif" width="12" height="13" border="0" alt="Check your Inbox" hspace="3" />{PRIVATE_MESSAGE_INFO}</a>&nbsp; &nbsp;<a href="{U_LOGIN_LOGOUT}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_login.gif" width="12" height="13" border="0" alt="Log out of Forums" hspace="3" />{L_LOGIN_LOGOUT}</a>&nbsp;</span>
					</tr></td><!-- BEGIN switch_user_logged_out --> 
<a href="{U_REGISTER}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_register.gif" width="12" height="13" border="0" alt="Join the Forum" hspace="3" />{L_REGISTER}</a>&nbsp;
						<!-- END switch_user_logged_out -->
				</table></td>
			</tr>
		</table>

		<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7317620270785635";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "FFFFFF";
google_color_bg = "F0F0F0";
google_color_link = "0000FF";
google_color_url = "008000";
google_color_text = "000000";
//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js">   
</script> 	<?php include "templates/subSilver/random_advertise.php"; ?> 

Last edited by nico_swd; 09-05-06 at 05:16 PM.
Reply With Quote
  #9 (permalink)  
Old 09-05-06, 04:50 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Hmm... Because this is within a template file (probably smarty), it is not being parsed by PHP and I believe the template output is being sent directly as HTML. I don't know how to get this to work in your case. Perhaps someone familiar with the template engine knows how to cause PHP content to be parsed.

If this was just a random image with a fixed link, it would be easy to get it to work. Because the random_advertise.php code actually echos a random link/random image the only way to get this to work is if the random_advertise.php file can be parsed as PHP.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Great Adult Chat - Forum Prawntickler General Advertisements 0 10-03-05 02:17 PM
Free phpBB Forum Hosting - Jconserv's FFH Network Psan General Advertisements 0 05-13-05 05:30 PM
Need some great members to my forum! rzpvile General Advertisements 0 03-03-05 03:06 PM
Great forum software for only 5 U.S Dollars! TheWarrior General Advertisements 0 10-26-04 10:37 AM


All times are GMT -5. The time now is 07:27 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.