Hey guys, I'm putting together a script that pulls a database for definitions... It's very straight forward. Pull the word and definition, which are each stored as fields in the definitions table. I would like the definitions to be able to have URLs in them. But when I just add the URL code to the text, it truncates the text where the URL is. Is there an easy way to pull text from SQL and have URLs to the text? Thanks, Sanzbar
Could you give us an example of the text that's giving you trouble. Do remember that if your text contains HTML code, you will have to use single quotes and not double quotes. Ex: Use <a href='http://www.mysite.com'>My Site</a> And not <a href="http://www.mysite.com">My Site</a> You'll have issues using the second format.
before you put any non numeric value into a database you should be cleaning your data first. I use php and mysql, any non numeric value I store I do $clean[$value]=mysql_real_escape_string($value); that will also take care of any issues with single or double quotes
That's not true. First of all, it's the single quotes that would cause issues (mostly with SQL injection) not double quotes. Second, depending on how your SQL query is formed, you can simply replace each single quote with two sets of single quotes and you're good to go. Here's an ASP code snippet I use for inserting into database. function SQLConvert (Term) if Term <> "" and not IsNull (Term) then Term = Replace (Term, chr (39), chr (39) & chr (39)) SQLConvert = Term end if end function Code (markup): And then to call it, you do something like this: Dim URL_Field URL_Field = "<a href=""" & Request.Form ("URL") & """>Some URL Text</a>" URL_Field = SQLConvert (URL_Field) (SQL Query here). Code (markup): All single quotes will be replaced with two single quotes, and you're good to go. Mind you, in the case of a URL, there should be some form of validation to ensure that the user inputted a proper URL and not just some random thing like "this is a URL, no really, it is, just ignore the commas and spaces." As far as retrieving, something like this would work: Dim URL_Field URL_Field = RS ("URL_Field") Response.Write "<a href=""" & URL_Field & """>some URL</a>" Code (markup): Any time you want to write double quotes, you just use two sets of them.
Good LORD! I am glad I that I ditched asp years ago - php is sooo much easier to understand $clean[$value]=mysql_real_escape_string($value); is much shorter to type