WEB I have a challenge! *PHP CREW*

Discussion in 'OT Technology' started by m3s3lf, Jul 25, 2008.

  1. m3s3lf

    m3s3lf *Jeep Crew*

    Joined:
    Oct 4, 2001
    Messages:
    5,460
    Likes Received:
    0
    Location:
    Sacramento, CA
    Code:
      
      function slicky_links($dirname, $filename, $page)
      {
        $imgurl = "http://www.slicky.net/gallery.php?cmd=midsize&gallery=$dirname&image=$filename";
        $linkurl = "http://www.slicky.net/gallery.php?gallery=$dirname&page=$page";
        
        $htmlcode = '<a href=' . $linkurl . '><img src=' . $imgurl . '></a>';
        
        echo "<a href=\"Javascript:copy('$htmlcode');\">HTML Code</a>";  
      }
    

    OK, so this function works well... It creates a link called "HTML Code" which copies the link code to my clipboard. An example of the copied text would look like this:
    Code:
    <a href=http://www.slicky.net/gallery.php?gallery=sample/&page=1><img src=http://www.slicky.net/gallery.php?cmd=midsize&gallery=sample/&image=IMG_0722.jpg></a>
    There's only one problem... the syntax is wrong. I need it to insert quotes around the image source url and the link url. I can't get it to work... it just keeps breaking up the original link code :mad:

    Anybody know how to fix0r it?
     
  2. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,923
    Likes Received:
    11
    Location:
    Los Angeles
  3. andrey

    andrey New Member

    Joined:
    Aug 12, 2006
    Messages:
    931
    Likes Received:
    0
    $htmlcode = '<a href="' . $linkurl . '"><img src="' . $imgurl . '"></a>';

    echo "<a href=\"javascript:copy('".addslashes($htmlcode)."');\">HTML Code</a>";

    This should work, but I've been coding for the past 5 hours so my brain is pretty dead.
     
  4. m3s3lf

    m3s3lf *Jeep Crew*

    Joined:
    Oct 4, 2001
    Messages:
    5,460
    Likes Received:
    0
    Location:
    Sacramento, CA
    Thanks for trying... here's the solution somebody came up with on another board. It seemed to work.

     

Share This Page