Recent Topics

1 Jan 03, 2008 04:17    

My b2evolution Version: 2.3.0-rc1

I made this random adsense script, but when I make it a FreeHTML widget it doesn't work. Any reason why?

	<?php
	   $random = (rand(0,100));
	?> 
    <?php
	   if($random > 50)
	   {
	?>
			<script type="text/javascript"><!--
            google_ad_client = "pub-XXXXXXXXXXX0578";
            //120x240, created 1/2/08
            google_ad_slot = "XXXXXX136";
            google_ad_width = 120;
            google_ad_height = 240;
            google_cpa_choice = ""; // on file
            //--></script>
            <script type="text/javascript"
            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
            </script>
	<?php
       }
       else
       {
    ?>
			<script type="text/javascript"><!--
            google_ad_client = "pub-XXXXXXXXXXX0578";
            //120x240, created 1/2/08
            google_ad_slot = "XXXXXX271";
            google_ad_width = 120;
            google_ad_height = 240;
            //--></script>
            <script type="text/javascript"
            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
            </script>
	<?php
	   }
	?>

2 Jan 03, 2008 04:22

Probably because it's not HTML ;)

The free html widget does not allow PHP code. HTML and, as far as I know, javascript are okay, but server-side stuff is simply not gonna work.

4 Jan 03, 2008 07:54

Just hardcode it to your skin instead :) That's what I did.

5 Jan 03, 2008 09:02

Cha-ching!!! Laibcoms wins the "you rock" prize for completing the answer. My bad yah?

6 Jan 03, 2008 17:43

Laibcoms,
I do have it hardcoded into my skin, but I wanted it above certain items.

7 Jan 03, 2008 18:00

Use an <iframe> in a freeHTML widget.

8 Jan 03, 2008 18:22

So I would put my ad script onto a separate HTML, than make the iFrame's source that page?

9 Jan 03, 2008 19:04

Or use javascript for the random if/else ;)

¥

10 Jan 03, 2008 19:18

This is what I have for Javascript only, but it isn't work... any help?


<script>
var number = Math.round(101*Math.random());
if (number > 50)
{
<!--
            google_ad_client = "pub-XXXXXXXXXXX0578";
            //120x240, created 1/2/08
            google_ad_slot = "XXXXXX136";
            google_ad_width = 120;
            google_ad_height = 240;
            google_cpa_choice = ""; // on file
            //-->
            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
}
else
{
<!--
            google_ad_client = "pub-XXXXXXXXXXX0578";
            //120x240, created 1/2/08
            google_ad_slot = "XXXXXXX271";
            google_ad_width = 120;
            google_ad_height = 240;
            //-->
            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
}
</script>

11 Jan 03, 2008 19:28

It needs to be more like this :

<script type="text/javascript">
<!--
var number = Math.round(101*Math.random());
if (number > 50)
{
            google_ad_client = "pub-XXXXXXXXXXX0578";
            //120x240, created 1/2/08
            google_ad_slot = "XXXXXX136";
            google_ad_width = 120;
            google_ad_height = 240;
            google_cpa_choice = ""; // on file
}
else
{
            google_ad_client = "pub-XXXXXXXXXXX0578";
            //120x240, created 1/2/08
            google_ad_slot = "XXXXXXX271";
            google_ad_width = 120;
            google_ad_height = 240;
}
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

¥


Form is loading...