PDA

View Full Version : My random problem!


trafix
04-05-2003, 02:05 AM
I am building a new banner hack to allow targeted sponsorship of nominated forums :)

If a forum is sponsored the approiate banner will be displayed with link.........THIS WORKS!

However if a forum is not sponsored then a random banner is to be selected from the list....THIS IS NOT WORKING :(

I have added this to forumdisplay.php
//############### start advertising / sponsorship banner #############
$showad = $DB_site->query_first("SELECT * FROM ads WHERE forumidnum='$forumid'");
if (empty($showad[forumidnum])) {
$randomad=$DB_site->query("SELECT * FROM ads ORDER BY rand() LIMIT 1");
eval("\$showthisad .= \"".gettemplate("ads_bannerbank")."\";");
} else {
eval("\$showthisad .= \"".gettemplate("ads_forum_sponsor")."\";");
}

Here is the ads_bannerbank template
<center><smallfont>Please support our sponsors<br>
<a target='blank' href='http://www.atmyparty.com/network/click.php?bannerid=$randomad[id]'>
<img border='0' width='$randomad[width]' heigth='$randomad[heigth]' alt='$randomad[banner_text]'
src='http://www.atmyparty.com/network/view.php?bannerid=$randomad[id]'></a>
<br>Please contact us to sponsor area of the site.<br><br></smallfont><center>


here is the source code of the non-sponsored page
<center><font face="verdana,arial,helvetica" size="1" >Please support our sponsors<br>
<a target='blank' href='http://www.atmyparty.com/network/click.php?bannerid='>
<img border='0' width='' heigth='' alt='' src='http://www.atmyparty.com/network/view.php?bannerid='>
</a><br>Please contact us to sponsor area of the site.<br><br></font><center>


What am i doing wrong?

thanks in advance

trafix
04-05-2003, 05:39 AM
Ok whilst I have been waiting I have been working on other areas of the hack....however i still have not been able to solve this problem yet.

I will start a new thread for my next hurdle,
I have nearly been able to complete targeting forums here the next hurdle is to target a particular script......eg....store.php

new thread here https://vborg.vbsupport.ru/showthread.php?s=&threadid=51200

mr e
04-05-2003, 06:40 PM
are you sure the cell will be empty?

if (empty($showad[forumidnum])) {


you could try

if (empty($showad[forumidnum]) or $showad[forumidnum] == 0)
{

trafix
04-05-2003, 10:10 PM
Hmmm thanks mr e,

I actually didnt think of that....doh...but it didnt work either I even tried
//############### start advertising / sponsorship banner #############
$showad = $DB_site->query_first("SELECT * FROM ads WHERE forumidnum='$forumid'");
if (empty($showad[forumidnum]) or $showad[forumidnum] =="") {
$randomad=$DB_site->query("SELECT * FROM ads ORDER BY RAND() desc LIMIT 1");
eval("\$showthisad .= \"".gettemplate("ads_bannerbank")."\";");
} else {
eval("\$showthisad .= \"".gettemplate("ads_forum_sponsor")."\";");
}

and it didnt work either

I only have 3 banners on the table so far and they do work when a target forum is nominated eg here i have also managed to make the ad banner to appear at the top of all threads in the nominated forum as well. i have even got it to display the sponsorship in the forum list. there are 2 sponsored forums here
http://www.atmyparty.com/network/forumdisplay.php?s=&forumid=172

I have attached a gif of the current data table, so i spose to answer your question....if you are viewing forum number 28 the cell more correctly is not there rather than empty. so by defult i want to display a random banner in the unsponsored forum/threads.

Thanks so far for your ideas...

trafix
04-05-2003, 10:17 PM
sorry but just to add to that the coding is displaying the right templates for both sponsored and unsponsored forums as the 2 templates are different....the problem is that the unsponsored forum has no image displayed.

Dean C
04-06-2003, 07:23 AM
I may be missing something here but why are you only selecting when there is no data? Should it be like this:


//############### start advertising / sponsorship banner #############
$showad = $DB_site->query_first("SELECT * FROM ads WHERE forumidnum='$forumid'");
if (!empty($showad[forumidnum]) or $showad[forumidnum] =="") {
$randomad=$DB_site->query("SELECT * FROM ads ORDER BY RAND() desc LIMIT 1");
eval("\$showthisad .= \"".gettemplate("ads_bannerbank")."\";");
} else {
eval("\$showthisad .= \"".gettemplate("ads_forum_sponsor")."\";");
}


That's what doesn't make sense to me :s

- miSt

trafix
04-06-2003, 08:05 AM
HIp hip horay.........after 2 bloody days the thing works...now to work out how to target a php file

https://vborg.vbsupport.ru/showthread.php?s=&threadid=51200

then its finished!

trafix
04-06-2003, 08:36 AM
<font size="4">THE HACK IS FINISHED!</font>

Now to get rid of phpnewads