Multiple Ads gives garbage results on archive

Discussion in 'Co-op Advertising Network' started by Infiniterb, Dec 7, 2004.

  1. #1
    Take a look towards the bottom of this page.

    http://www.clantt.com/vb/archive/index.php

    I'm using the following code:

    include ('ad_network.php');
    include ('ad_network.php');
    include ('ad_network.php');
    include ('ad_network.php');
    include ('ad_network.php');
    echo $ad_network[0] | $ad_network[1] | $ad_network[2] | $ad_network[3] | $ad_network[4];


    Is that not correct?
     
    Infiniterb, Dec 7, 2004 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    Hmmm... that's interesting. :) Same ad_network.php file you are using for the base of your forums?
     
    digitalpoint, Dec 7, 2004 IP
  3. Infiniterb

    Infiniterb Well-Known Member

    Messages:
    1,314
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    168
    #3
    Yeah, it's stored in the domain/vb/ folder (just updated it too).

    You seem to be following me around :)
     
    Infiniterb, Dec 7, 2004 IP
  4. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #4
    That's really bizarre since it works on the main forum. Try replacing the echo with:
    print_r ($ad_network);
    PHP:
    and see if the array prints out normally.

    BTW, with the new ad_network.php file, you only need to include once (in the archive and the phpinclude_start template.
     
    digitalpoint, Dec 7, 2004 IP
  5. Infiniterb

    Infiniterb Well-Known Member

    Messages:
    1,314
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    168
    #5
    Ok, so I replaced the entire line:

    echo $ad_network[0] | $ad_network[1] | $ad_network[2] | $ad_network[3] | $ad_network[4];

    With the:

    Print_r ($ad_Network);

    And now I'm getting 5 ads.
     
    Infiniterb, Dec 7, 2004 IP
  6. rvarcher

    rvarcher Peon

    Messages:
    69
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    echo $ad_network[0] | $ad_network[1] | $ad_network[2] | $ad_network[3] | $ad_network[4];

    This line will casue problems because of the unquoted |

    you would need to put it all in quotes like:

    echo "$ad_network[0] | $ad_network[1] | $ad_network[2] | $ad_network[3] | $ad_network[4]";

    but a better, neater way is to use PHPs implode funciton which glues all items in an array together with whatever "glue" you specify.

    echo implode (" | ", $ad_network);

    - bob
    http://www.tropicrentals.com
     
    rvarcher, Dec 7, 2004 IP
  7. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #7
    Wait a minute... is that a direct copy/paste of the echo line? If so, I have no idea what it would give you with the pipe, but it wouldn't echo it (maybe some sort of OR variation). The proper syntax would be:
    echo $ad_network[0] . ' | ' . $ad_network[1] . ' | ' . $ad_network[2] . ' | ' . $ad_network[3] . ' | ' . $ad_network[4];
    PHP:
    But a cleaner/shorter way to do it is like so:
    echo implode (' | ', $ad_network);
    PHP:
    Edit: Oops... someone beat me to it. :)
     
    digitalpoint, Dec 7, 2004 IP
  8. rvarcher

    rvarcher Peon

    Messages:
    69
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Ok Shawn, I'm a newbie. How do I do the quote box?

    - bob
     
    rvarcher, Dec 7, 2004 IP
  9. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #9
    digitalpoint, Dec 7, 2004 IP
  10. Infiniterb

    Infiniterb Well-Known Member

    Messages:
    1,314
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    168
    #10
    Works perfectly using echo implode (' | ', $ad_network);

    Thanks all for the help!
     
    Infiniterb, Dec 7, 2004 IP
  11. chops

    chops Well-Known Member

    Messages:
    199
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    140
    #11
    Sorry if I'm thick at php, but could someone give me the exact code to copy/paste to my page footer so that I can have 5 coop ads per page. I've fiddled with the above but got nowhere!
     
    chops, Dec 8, 2004 IP
  12. rvarcher

    rvarcher Peon

    Messages:
    69
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Post the section that you're trying to get to work.
     
    rvarcher, Dec 8, 2004 IP
  13. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #13
    echo implode (' ', $ad_network);
    PHP:
     
    digitalpoint, Dec 8, 2004 IP
  14. chops

    chops Well-Known Member

    Messages:
    199
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    140
    #14
    I am sorry I still can't figure it out. Here is the code that I have in my footer, which produces one coop ad.
    Can anyone please show me what to replace it with in full, to get 5 ads. Thanks
    <?php ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    include ('ad_network.php');
    echo $ad_network[0]; ?>
     
    chops, Dec 8, 2004 IP
  15. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #15
    replace the echo line with the one shown above.
     
    digitalpoint, Dec 8, 2004 IP
  16. chops

    chops Well-Known Member

    Messages:
    199
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    140
    #16
    <?php
    ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    include ('ad_network.php');
    echo implode (' ', $ad_network);

    ?>

    I've done it. It works, but it shows just one ad.
     
    chops, Dec 8, 2004 IP
  17. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #17
    What shows if you add:
    print_r ($ad_network);
    PHP:
     
    digitalpoint, Dec 8, 2004 IP
  18. chops

    chops Well-Known Member

    Messages:
    199
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    140
    #18
    Car Hire IbizaArray ( [0] => Car Hire Ibiza )
    Shows with this code:

    <?php
    ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    include ('ad_network.php');
    echo implode (' ', $ad_network); print_r ($ad_network);

    ?>
     
    chops, Dec 8, 2004 IP
  19. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #19
    Are you sure you are using the latest ad_network.php file?
     
    digitalpoint, Dec 8, 2004 IP
  20. chops

    chops Well-Known Member

    Messages:
    199
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    140
    #20
    YES!!! now it works...Thank you!
    I've updated the ad_network.php file
    and used this on each page:
    <?php
    ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    include ('ad_network.php');
    echo implode (' ', $ad_network);
    ?>

    I get one boxed link and four plain text links.
     
    chops, Dec 9, 2004 IP