Site Links
Home
Features
Documentation
Pricing & Order
Members Area
Support Options
UBBDev.com
UBBWiki.com
Who's Online
5 registered (Iann128, GregK, SteveS, SD, ayawkho), 39 Guests and 15 Spiders online.
Key: Admin, Global Mod, Mod
Featured Member
Registered: 03/21/08
Posts: 224
Top Posters (30 Days)
Ruben 61
SD 52
Gizmo 48
gliderdad 33
Dunny 21
driv 18
dbremer 16
Mark S 13
Stan 12
Iann128 10
Latest Photos
OK Corral Shoot Out
Testing
Basildon Train Station
Basildon Town Centre looking from the rounderbout
Basildon Town Square
Page 1 of 3 1 2 3 >
Topic Options
#235139 - 02/25/10 06:56 PM Custom Island - Banner rotation Code
Wisc.Tiger Offline
journeyman
Registered: 07/30/07
Posts: 93
Loc: WI
This is what I have inserted into Custom Island, using this ad Ad Island.

Quote:
/* PHP CODE HERE */

/* BODY HERE */
$body =
$bannerAd[1] = 'http://www.germanshepherdhome.net/testadbanner1.jpg';
$bannerAd[2] = 'http://www.germanshepherdhome.net/testadbanner2.jpg';
$bannerAd[3] = 'http://www.germanshepherdhome.net/testadbanner3.jpg';

$adCount = count($bannerAd);
$randomAdNumber = mt_rand(1, $adCount);
echo $bannerAd[$randomAdNumber];
<<<EOF
EOF;


So that shows up is just the url


What did I do wrong??? Some day I will learn php

Val
_________________________
http://germanshepherdhome.net
Top
Express Hosting
Express Hosting "We are the official hosting company of UBB.threads. Ask us about our free migration services to migrate your UBB.threads installation."
#235140 - 02/25/10 07:15 PM Re: Custom Island - Banner rotation Code [Re: Wisc.Tiger]
gliderdad Offline
Registered: 06/08/06
Posts: 1438
Loc: NY
You need to put the code between the

<<<EOF

EOF;

So you should be

Code:
/* PHP CODE HERE */
$body = <<<EOF

$bannerAd[1] = 'http://www.germanshepherdhome.net/testadbanner1.jpg';
$bannerAd[2] = 'http://www.germanshepherdhome.net/testadbanner2.jpg';
$bannerAd[3] = 'http://www.germanshepherdhome.net/testadbanner3.jpg';

$adCount = count($bannerAd);
$randomAdNumber = mt_rand(1, $adCount);
echo $bannerAd[$randomAdNumber];
EOF;
Top
#235141 - 02/25/10 07:27 PM Re: Custom Island - Banner rotation Code [Re: Wisc.Tiger]
SD Online   partay
Registered: 04/19/07
Posts: 4031
Loc: SoCal, USA
Php Code:
/* PHP CODE HERE */

$Ads = array (
	'http://www.germanshepherdhome.net/testadbanner1.jpg',
	'http://www.germanshepherdhome.net/testadbanner2.jpg',
	'http://www.germanshepherdhome.net/testadbanner3.jpg'
	);


/* BODY HERE */
$body = <<<EOF
 $Ads[mt_rand(0, count($Ads)-1)]
EOF; 


might work

Remember array index starts from 0 there wink

Also, i'd recommend (if i were you) to put your banners in something like /forums/images/banners directory. That way you don't clutter up your site's root dir.. if you do, you'd need to modify the URLs above, but you get the drift smile
_________________________

Threads tutorials . Threads & Wordpress experts . UBB resume

If I you, click this link as to why
Top
#235142 - 02/25/10 08:25 PM Re: Custom Island - Banner rotation Code [Re: SD]
Wisc.Tiger Offline
journeyman
Registered: 07/30/07
Posts: 93
Loc: WI
SD,

I did copy and paste on your code got this error

Quote:
Parse error: parse error, unexpected $ in /home/content/t/i/g/tiger2/html/germanshepherdhome/forum/cache_builders/custom/portal_box_1.php on line 16
_________________________
http://germanshepherdhome.net
Top
#235143 - 02/25/10 08:28 PM Re: Custom Island - Banner rotation Code [Re: Wisc.Tiger]
Wisc.Tiger Offline
journeyman
Registered: 07/30/07
Posts: 93
Loc: WI
Gliderdad, I copied and pasted the code you posted and all I get the Island box is

Quote:
= 'http://www.germanshepherdhome.net/testadbanner1.jpg'; = 'http://www.germanshepherdhome.net/testadbanner2.jpg'; = 'http://www.germanshepherdhome.net/testadbanner3.jpg'; = count(); = mt_rand(1, ); echo ;
_________________________
http://germanshepherdhome.net
Top
#235144 - 02/25/10 08:42 PM Re: Custom Island - Banner rotation Code [Re: Wisc.Tiger]
SD Online   partay
Registered: 04/19/07
Posts: 4031
Loc: SoCal, USA
yah, i left off a ')'

updated the post now..

i keep forgetting to match the number of ('s to )'s and arrays use [] too! laugh
_________________________

Threads tutorials . Threads & Wordpress experts . UBB resume

If I you, click this link as to why
Top
#235145 - 02/25/10 08:50 PM Re: Custom Island - Banner rotation Code [Re: SD]
gliderdad Offline
Registered: 06/08/06
Posts: 1438
Loc: NY
SD's is correct not mine, forgot to move the php to where it should be
Top
#235146 - 02/25/10 08:55 PM Re: Custom Island - Banner rotation Code [Re: gliderdad]
SD Online   partay
Registered: 04/19/07
Posts: 4031
Loc: SoCal, USA
Custom island syntax has been a bugaboo, because it's not obvious what is php and what is not..

In actuality, the ENTIRE code block is, since the custom island code that UBB.threads uses to save it simply puts <?php and ?> around it.

The only thing you MUST have in your code is the last 3 lines.. where 1 of them assigns to the body a value. the EOF; is key too, since the save code keys upon it.

Linky Poo to a tutorial in progress about how it works.. that one is for a different application of custom island, but the concept remains the same smile
_________________________

Threads tutorials . Threads & Wordpress experts . UBB resume

If I you, click this link as to why
Top
#235147 - 02/25/10 09:38 PM Re: Custom Island - Banner rotation Code [Re: SD]
Wisc.Tiger Offline
journeyman
Registered: 07/30/07
Posts: 93
Loc: WI
SD,

Another error message
Quote:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ']' in /home/content/t/i/g/tiger2/html/germanshepherdhome/forum/cache_builders/custom/portal_box_1.php on line 13
_________________________
http://germanshepherdhome.net
Top
#235149 - 02/25/10 10:05 PM Re: Custom Island - Banner rotation Code [Re: Wisc.Tiger]
SD Online   partay
Registered: 04/19/07
Posts: 4031
Loc: SoCal, USA
Php Code:
# Le Pee H Pee
$Ads = array (
	"http://www.germanshepherdhome.net/testadbanner1.jpg",
	"http://www.germanshepherdhome.net/testadbanner2.jpg",
	"http://www.germanshepherdhome.net/testadbanner3.jpg"
	);

$adNum = mt_rand(0, count($Ads)-1);

# The body!
$body = <<<EOF
 <img src="{$Ads[$adNum]}" />
EOF; 


Try that. I typed it up too quick smile

I put it on my test site for you to see Linky Dinky
_________________________

Threads tutorials . Threads & Wordpress experts . UBB resume

If I you, click this link as to why
Top
Page 1 of 3 1 2 3 >



Moderator:  AllenAyres, Harold, Ian, Ron M 
Shout Box

Today's Birthdays
No Birthdays
Recent Topics
Edit Post
by Bert
Today at 01:19 PM
A positive note
by SteveS
Yesterday at 09:36 PM
How to locate links to particular site if they are only used in images?
by Conrad
02/10/12 09:41 PM
Pictures not displaying
by Marker23
02/09/12 10:04 PM
Issue with logging out constantly
by Flanuva
02/09/12 07:05 PM
Forum Stats
10214 Members
36 Forums
33667 Topics
180917 Posts

Max Online: 978 @ 06/24/07 11:19 PM
Random Image