Hey.
I have made a code, so that everytime you load the page, it randomly selects wether it sould be an ad or a picture to be there.
I think Im allmost finished with the code, But it have some errors. Example, that when it sould show an ad it shows nothing.
I will list 2 files in here, The functions.php and the Index.php.
Functions.php
<?php
function display_adsense() {
echo "
<script type='text/javascript'><!--
google_ad_client = 'pub-7631840574101908';
/* 300x250, oprettet 21-08-09 */
google_ad_slot = '1626493265';
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type='text/javascript'
src='http://pagead2.googlesyndication.com/pagead/show_ads.js'>
</script>";
}
function random_ad() {
echo "
<script language='JavaScript'>
images = new Array(2);
images[0] = '<?php display_adsense() ?>';
images[1] = '<img src=wp-content/themes/wp-symisun/images/ad_test_1.PNG></img>';
index = Math.floor(Math.random() * images.length);
document.write(images[index]);
</script>";
}
?>
Index.php
<?php random_ad() ?>
I have not posted the Fully index.php or the fully functions.php, But this is the only thing that haves an error.
Can anybody tell me what the problem is?