+ Reply to Thread
Results 1 to 3 of 3

 

Thread: using php to print TD javascript code

  1. #1
    Registered User

    Status
    Offline
    Join Date
    Jan 2005
    Location
    London
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts


    Hi,

    I hope somebody can help me check if my code is ok.

    I am storing Trade doubleR javascript textlinks in my DB, i try and replace the actual text in the link with my own text

    this is the data held in the table column

    <a href="http://clkuk.tradedoubler.com/click?p=XXXXX&a=XXXXXX&g=XXXXXX" target="_blank">$text</a><script language="javascript">var uri = 'http://impgb.tradedoubler.com/imp/inv/XXXXXX/XXXXXXX?' + new String (Math.random()).substring (2, 11);document.write('<img src="'+uri +'">');</script>

    and store this in a variable e.g. $dbtext


    I replace the actual text of the link with #$text# so i can write my own text in its place by using EVAL()

    ....


    $isp_link = $dbtext // $dbtext = TD code in db

    $data = addslashes($isp_link); // i add slashed cos the javascript in the TD code has apostrophes all over the place

    $text =" Whoohoo heres my own text"; //this text really comes from another table col !


    eval('$data = "' . $data . '";'); //DO STRING TRANSFORMATION so that the value $text in $isp_link is replaced with my own text which really comes from another column in the table!

    echo "<span class=enquirelink>$data</a></span>";


    ------------------

    so all this stuff prints out this source

    <span class="enquirelink"><a href="http://clkuk.tradedoubler.com/click?p=XXXXX&amp;a=XXXXXXXX&amp;g=XXXXX" target="_blank">Whoohoo heres my own text</a><script language="javascript">var uri = \'http://impgb.tradedoubler.com/imp/inv/XXXXX/XXXXXXX?\' + new String (Math.random()).substring (2, 11);document.write(\'<img src="\'+uri +\'">\');</script></span>


    ---------------

    so is this link ok ? are my clicks going to be tracked ok? is there a better way to do this ?

    i have magic quotes on btw.

    thanks all

  2. #2
    Super Member

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Costa Del Sheffield
    Posts
    2,838
    Thanks
    5
    Thanked 18 Times in 14 Posts
    id just store the actual link in a db column such as:

    http://clkuk.tradedoubler.com/click?...XXXXX&g=XXXXXX

    then when you come to printing it out you would just have
    echo "<a href=\"$link\">$text</a>";

    all the javascript stuff isnt really needed. and you can pick up the text links from the link matrix which is quicker than going into each program page and getting them from there.

    also you could then just add tracking to the end on links if you wanted like...

    echo "<a href=\"$link&epi=FooterLink\">$text</a>";

    the link you have there (in your post) should track as it goes through the td tracking thing but the

    Code:
    <script language="javascript">var uri = 'http://impgb.tradedoubler.com/imp/inv/XXXXXX/XXXXXXX?' + new String (Math.random()).substring (2, 11);document.write('<img src="'+uri +'">');</script>
    after the actual link isnt of much use.
    Dan Morley
    alpharooms.com
    daniel at alpharooms dot com - Hotels, Flights, Airport Transfers, Care Hire + More! sign up
    My Blog | Cheap Holidays

  3. #3
    Registered User

    Status
    Offline
    Join Date
    Jan 2005
    Location
    London
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thats very helpfull!

    cheers Dan

+ Reply to Thread


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2