SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Why won't this work?

    <?php

    if ($style == "oblivionstyle") {
    $adcolour="#000000";
    }

    if ($style == "hexstyle") {
    $adcolour="#000000";
    }

    if ($style == "mainstyle") {
    $adcolour="#012349";
    }

    if ($style == "") {
    $adcolour="#012349";
    }

    ?>




    <script type="text/javascript"><!--
    google_ad_client = "pub-1527442551569821";
    google_ad_width = 120;
    google_ad_height = 240;
    google_ad_format = "120x240_as";
    google_ad_type = "text_image";
    google_ad_channel ="";
    google_color_border = "012349";
    google_color_bg = "<?php echo '$adcolour' ?>"
    google_color_link = "012349";
    google_color_text = "000000";
    google_color_url = "00CCFF";
    //--></script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>

    The colour is not changing?

    Regards,
    Neil

  2. #2
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    California
    Posts
    267
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    PHP Code:
    <?php
      
    if ($style == "oblivionstyle") {
      
    $adcolour="#000000";
      }
      
      if (
    $style == "hexstyle") {
      
    $adcolour="#000000";
      }
      
      if (
    $style == "mainstyle") {
      
    $adcolour="#012349";
      }
      
      if (
    $style == "") {
      
    $adcolour="#012349";
      }
      
    ?>
      
      <script type="text/javascript"><!--
      google_ad_client = "pub-1527442551569821";
      google_ad_width = 120;
      google_ad_height = 240;
      google_ad_format = "120x240_as";
      google_ad_type = "text_image";
      google_ad_channel ="";
      google_color_border = "012349";
      google_color_bg = "<?php echo $adcolour?>"
      google_color_link = "012349";
      google_color_text = "000000";
      google_color_url = "00CCFF";
      //--></script>
      <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
      </script>
    You were echoing the string "$adcolour" instead of the variable $adcolour. If you had used double-quotes ("$adcolour") it would have also worked, but you used single-quotes ('$adcolour') which will not get the variable's value.
    The Banana Stand - an Arrested Development fansite
    LC-3 Help - tutorials on the LC-3 educational assembly language

  3. #3
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry but it still shows white instead of the colour!

    Thanks

    Neil

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Right click, view source.

  5. #5
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the page code:

    google_ad_channel ="";


    So why isn't the value of the colour being put in there?

    Regards,
    Neil

  6. #6
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    look at your php code and you will see why.

  7. #7
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I really cannot what is wrong?

  8. #8
    SitePoint Zealot scojo1's Avatar
    Join Date
    Aug 2005
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rctneil
    I really cannot what is wrong?

    how are you setting the $style variable?

  9. #9
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Sorry, i get ya, the style varibale is like this:

    www.example.com?style=oblivion

  10. #10
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Is register_globals enabled on this server?

    You should be using $_GET['style'] to access that.

  11. #11
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you asked why the value of this is empty
    google_ad_channel ="";

    did you mean to ask why this is empty?
    google_color_bg = ""

    thats why i said look at your code.

  12. #12
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    All sorted, I have a hash in my code where i shouldn't have done


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •