![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a photo album page where I pull captions and such from an SQL database and inject into the resulting HTML. My problem is with the use of an apostrophe (single quote) and other such characters as they break my HTML. I'm also using javascript and it's a problem there as well. The method I use to insert such characters works without problems. In the SQL I get what was intended... e.g. Ginny's Wedding However when I pull it out I get this: (seemingly correct) a href="album.php?albumid=293&frompage=1"><img id="img_two" src="data/293/0/cover3.jpg" alt="Ginny's Wedding" onMouseOver="switchit('Ginny's Wedding - Jun 11 2005');" onMouseOut="clearit();"></a><br ...But then my JS broken because the text is in single quotes and another extra one breaks it. How should I store such characters in SQL, or maybe just how should I read them out so they can't break my code, yet they show up on the screen fine? -- Shawn Wilson |
#3
| |||
| |||
|
|
Shawn Wilson wrote: I have a photo album page where I pull captions and such from an SQL database and inject into the resulting HTML. My problem is with the use of an apostrophe (single quote) and other such characters as they break my HTML. I'm also using javascript and it's a problem there as well. The method I use to insert such characters works without problems. In the SQL I get what was intended... e.g. Ginny's Wedding However when I pull it out I get this: (seemingly correct) a href="album.php?albumid=293&frompage=1"><img id="img_two" src="data/293/0/cover3.jpg" alt="Ginny's Wedding" onMouseOver="switchit('Ginny's Wedding - Jun 11 2005');" onMouseOut="clearit();"></a><br ...But then my JS broken because the text is in single quotes and another extra one breaks it. How should I store such characters in SQL, or maybe just how should I read them out so they can't break my code, yet they show up on the screen fine? You're twice off topic. First, because this is a MySQL NG. We don't deal with HTML, PHP, or JS here. Second, because this is an Italian language NG. |
#4
| |||
| |||
|
|
Shawn Wilson You're twice off topic. First, because this is a MySQL NG. We don't deal with HTML, PHP, or JS here. Second, because this is an Italian language NG. gmax |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
I have a photo album page where I pull captions and such from an SQL database and inject into the resulting HTML. My problem is with the use of an apostrophe (single quote) and other such characters as they break my HTML. I'm also using javascript and it's a problem there as well. The method I use to insert such characters works without problems. In the SQL I get what was intended... e.g. Ginny's Wedding [snip] |
#7
| |||
| |||
|
|
On Fri, 16 Sep 2005 21:09:04 GMT, "Shawn Wilson" shawnw_nospam_ (AT) _nospam_dvigroup (DOT) net> wrote: I have a photo album page where I pull captions and such from an SQL database and inject into the resulting HTML. My problem is with the use of an apostrophe (single quote) and other such characters as they break my HTML. I'm also using javascript and it's a problem there as well. The method I use to insert such characters works without problems. In the SQL I get what was intended... e.g. Ginny's Wedding [snip] [newsgroups trimmed] There are two possible solutions. 1. Escape the apostrophe with a backslash, e.g. Ginny\'s Wedding. IIRC, this is universally recognized by Javascript, PHP, etc. 2. Use the extended ASCII symbol HTML code for the apostrophe, e.g. Ginny's Wedding. For future reference, you can consult this chart: http://www.bbsinc.com/symbol.html For more info on using escape codes in javascript: http://www.devx.com/tips/Tip/13618 This is all pretty basic Javascript stuff. A quick search on Google reveals thousands of sites with references to escape codes, etc. |
![]() |
| Thread Tools | |
| Display Modes | |
| |