Storing Hyperlinks in Databases

Discussion in 'MySQL' started by jim_h, Feb 12, 2006.

  1. #1
    I've got an issue with trying to store some affiliate links in my database. They require you to use a linked image so I figured instead of breaking the code up, I'd just put the html code in its entirety into a text field in my MySQL db.
    For some reason I get nothing out of it when I query it and call it on a webpage with PHP. I've checked with the vendor of the software that I used to create the insert forms and they've covered the addslashes/stripslashes so it can't be that.
    I guess my question is, is this even possible? Am I storing it in the wrong type of field? (TEXT currently).

    Any help is appreciated.
     
    jim_h, Feb 12, 2006 IP
  2. arnek

    arnek Active Member

    Messages:
    134
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #2
    arnek, Feb 13, 2006 IP
  3. mariush

    mariush Peon

    Messages:
    562
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #3
    In some cases, stripslashes may not be enough.

    I'm using this custom function, i've tested this even with complete 20 K html pages ( worked on some kind of a cache system):

    
    function sqlesc($x)
    {
    	 $value = $x;
    	 // Stripslashes
       if (get_magic_quotes_gpc()) 
       {
           $value = stripslashes($value);
       }
       // Quote if not integer
       if (!is_numeric($value)) {
           $value = "'" . mysql_real_escape_string($value) . "'";
       }
       return $value;
    }
    
    PHP:
     
    mariush, Feb 13, 2006 IP
  4. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #4
    they are probably stripping all the html entities including links and tags or something.

    You can store any type of html in a text or varchar field as long as you don't use some php function to alter it.
     
    mad4, Feb 13, 2006 IP