473,383 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

database item and apostrophe

Hey guys,

Small problem...

On my site:

<Link removed>

Apostrophes stop any more text after it showing in link titles.

For example, on the right hand side half way down the page the album name:

You're The Designers, We're The Deciders for the band Not Advised.

if you hover, or check the source - it stops at You.

The code is:

Expand|Select|Wrap|Line Numbers
  1. echo "</td><td class='listingtitle'>Artist: <b></td><td><a href='http://megalyrics.net/search.html?c=".$row[artist]."' alt='View ".$row[artist]." Lyrics' title='View ".$row[artist]." Lyrics'>".$row[artist]."</a></b></td></tr><tr><td class='listingtitle'>Album:</td><td><a href='http://megalyrics.net/search.html?c=".$row[album]."' title='View ".$row[album]." Lyrics' title='View ".$row[album]." Lyrics'>".$row[album]."</a></td></tr><tr><td class='listingtitle'>Views:</td><td><font color='#444444'>".$row[views]."</font></td></tr>";
  2.  

Any ideas why it is stopping at the apostrophe in the generated code and how it can be fixed??
Dec 13 '09 #1
2 2472
Atli
5,058 Expert 4TB
Hey.

You need to make sure the quote-marks add up. That the apostrophe in the Artist name isn't messing with the single-quotes that mark the start and end of the string in the HTML markup.
Expand|Select|Wrap|Line Numbers
  1. <a title='This is John's name.' ..>
There the apostrophe in "John's" will close the string used for the title attribute. The rest of the value would be thrown away as garbage text that doesn't belong. The third single-quote, that you meant to be the end of the string, might even cause further collateral damage, causing the following tags to be ignored as a part of a random string that belongs nowhere.

You can use the htmlentities function to convert plain-text apostrophes into their HTML equivalents, which you can then safely echo into your markup.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $title = "John's name";
  3. $title = htmlentities($title, ENT_QUOTES, 'UTF-8');
  4.  
  5. echo "<a title='{$title}' href='#'>Test</a>";
  6.  
  7. // Result:  <a title='John&#39;s name' href='#'>Test</a>
  8. ?>
&#39; is the HTML equivalent to a single-quote, and will be displayed as such in the output.
Dec 13 '09 #2
clain
79
yess ..!!! just use Double quotes where there is chance of single quotes...!!

or Try Escaping the single quote with additional single quote
Dec 14 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: John | last post by:
I am having problems with special characters with database calls (if I'm referring to this in the right way). the problem is with apostrophes of all things. If an end user puts an apostrophe in...
13
by: Richard Hollenbeck | last post by:
To prevent future apostrophe bugs and errors, isn't it just simpler to forbid an apostrophe from being entered into a text field? For example, couldn't "Alice's Restaurant" be changed to "Alices...
1
by: Rose | last post by:
Hi all, I'm trying to create a clickable link, but the pesky apostrophe is preventing the link from getting displayed properly. I'm displaying the contents of a folder (with contains the...
10
by: Bhavna | last post by:
I am using a Replace function to replace single quotes with double when submitting a text field in the database i.e. Replace (q, "'", "' ' ") which works fine. When I retrieve the field from the...
14
by: Mikee Freedom | last post by:
Good Morning all, New member to the list, hoping you might be able to give me some much needed advice. Basically, I have a client who would like to offer the ability for his users to have...
12
by: Robbo | last post by:
Hi, My database contains 45 tables the structure of which is evolving as I develop. I need a utility that will "read" the structure of this database and it's tables and then create an identical...
2
by: mister-Ed | last post by:
I have a datagrid, and when initializing my field variables, I need to double up apostrophes so they are accepted into SQL dbase. In the line below, i'm trying to do this with the Replace function,...
3
by: pitchblack408 | last post by:
Hello I am using excel as my database and when I do an insert there is an apostrophe that appears in the cell where a string was inserted. For example '(474)343-3433 It appears that the...
9
by: Thomas 'PointedEars' Lahn | last post by:
Jukka K. Korpela wrote: IBTD. For example, in English it is customary (and AIUI expected) to use the character that ’ represents should be used to delimit a quotation within direct speech...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.