I have a site that I host for a client that is having problems with the apostrophes in the text it draws from the database. Here is a link to the live site that is having the issue. I think it has to do with the addslashes php function but I am not sure. If it is a global php setting please let me know. Any help is greatly appreciated.

This is the code for that page

<?

include_once('./db.php');

function Get_Nix()
{
    $sql = "SELECT * FROM nix WHERE position IS NOT null ORDER BY position ASC LIMIT 1";
    $result = mysql_query($sql);
    $numRows = mysql_num_rows($result);
    if($numRows == 0)
    {
        echo "Sorry, no nixit is available this month.";
    }
    else
    {
        while($row = mysql_fetch_assoc($result))
            {
                extract($row);
                $nix = nl2br($nix);
?>                

                        <p class="small"><? 
                            echo $title."<br><br>"; 
                            echo $nix."&nbsp;&nbsp;<img src=\"../images/house.gif\" border=\"0\">";
                        
                        ?></p>
                
<?                    
            }    
    }
}

function Get_TAT()
{
    $sql = "SELECT * FROM tip WHERE position IS NOT null ORDER BY position ASC LIMIT 2";
    $result = mysql_query($sql);
    $numRows = mysql_num_rows($result);
    if($numRows == 0)
    {
        #echo "Sorry, no departments were found.";
    }
    else
    {
        while($row = mysql_fetch_assoc($result))
            {
                extract($row);
                $tip = nl2br($tip);
?>                
                 <p class="bodystyle"><? echo $title."<br><br>"; 
                 echo $tip."&nbsp;&nbsp;<img src=\"../images/house.gif\" border=\"0\">" ?></p><br><br>
                     
<?                    
            }    
    }
}
?>


<HTML><!-- InstanceBegin template="/Templates/inside.dwt.php" codeOutsideHTMLIsLocked="false" -->
<HEAD>
<!-- InstanceBeginEditable name="doctitle" -->
<TITLE>Ask Priscilla</TITLE>
<!-- InstanceEndEditable --> 
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<link href="../main.css" rel="stylesheet" type="text/css">
</HEAD>

<BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 onLoad="MM_preloadImages('../images/navigation_contact_r.gif','../images/navigation_home_r.gif','../images/navigation_ask_r.gif','../images/navigation_news_r.gif','../images/navigation_read_r.gif','../images/navigation_book_r.gif','../images/navigation_bio_r.gif')">
<a name="top"></a> 
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td align="left" valign="top" height="5"><table width="100%" height="99" border="0" cellpadding="0" cellspacing="0">
        <tr bgcolor="0A4903"> 
          <td align="left"><IMG SRC="../images/top_bar_priscilla.jpg" ALT="" WIDTH=138 HEIGHT=99 border="0"></td>
          <td align="center"><a href="../index.php"><IMG SRC="../images/top_bar_ask.gif" ALT="" WIDTH=305 HEIGHT=99 border="0"></a></td>
          <td align="right" bgcolor="0A4903"><img src="../images/top_bar_book.gif" width="279" height="99" border="0" usemap="#Map" href="#http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?userid=ZYw1F6Dw0Z&amp;isbn=1890206210&amp;itm=1"></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td align="left" valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="131" rowspan="3" align="left" valign="top" background="../images/inside_shading.jpg"> 
            <TABLE WIDTH=131 BORDER=0 CELLPADDING=0 CELLSPACING=0>
              <TR> 
                <TD width="131" background="../images/inside_shading.jpg"> 
                  <a href="../index.php" onMouseOver="MM_swapImage('Image1','','../images/navigation_home_r.gif',1)" onMouseOut="MM_swapImgRestore()"><IMG SRC="../images/navigation_home.gif" ALT="" name="Image1" WIDTH=131 HEIGHT=28 border="0" id="Image1"></a></TD>
              </TR>
              <TR> 
                <TD> <a href="ask_priscilla.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image13','','../images/navigation_ask_r.gif',1)"><img src="../images/navigation_ask.gif" name="Image13" width="131" height="27" border="0"></a></TD>
              </TR>
              <TR> 
                <TD> <a href="ask_news.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image14','','../images/navigation_news_r.gif',1)"><img src="../images/navigation_news.gif" name="Image14" width="131" height="27" border="0"></a></TD>
              </TR>
              <TR> 
                <TD> <a href="book_samplings.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image15','','../images/navigation_read_r.gif',1)"><img src="../images/navigation_read.gif" name="Image15" width="131" height="27" border="0"></a></TD>
              </TR>
              <TR> 
                <TD><a href="priscilla_book.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image16','','../images/navigation_book_r.gif',1)"><img src="../images/navigation_book.gif" name="Image16" width="131" height="27" border="0"></a></TD>
              </TR>
              <TR> 
                <TD> <a href="author_bio.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image17','','../images/navigation_bio_r.gif',1)"><img src="../images/navigation_bio.gif" name="Image17" width="131" height="27" border="0"></a></TD>
              </TR>
              <TR> 
                <TD> <a href="contact.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image18','','../images/navigation_contact_r.gif',1)"><img src="../images/navigation_contact.gif" name="Image18" width="131" height="32" border="0"></a></TD>
              </TR>
            </TABLE></td>
          <td align="left" valign="top" background="../images/inside_shading.jpg"><table width="475" height="100%" border="0" align="left" cellpadding="0" cellspacing="10">
              <tr> 
                <td align="left" valign="top" class="bodystyle"><!-- InstanceBeginEditable name="main body" --> 
                  <img src="../images/head_news.gif" border="0"> <br>
                  <? Get_TAT(); ?>
                  <!-- InstanceEndEditable --> </td>
              </tr>
            </table> </td>
          <td width="206" rowspan="3" align="left" valign="top" background="../images/inside_bar.gif"><IMG SRC="../images/inside_bar_shading.gif" WIDTH=206 HEIGHT=8 ALT=""><br> 
            <table width="200" border="0" align="right" cellpadding="0" cellspacing="10" class="sidebar">
              <tr> 
                <td align="left" valign="top"><!-- InstanceBeginEditable name="sidebar" --> 
                  <img src="../images/head_nixit.gif" width="92" height="36" border="0"><br>
                  <? Get_Nix(); ?>
                  <br>
                  <br>
                  <br>
                  <hr size="1" noshade>
                  <span class="small"><strong>* Nix&middot;it (nicks &middot; 
                  it) v.</strong><br>
                  1. to do away with, especially when it comes to home decorating.<br>
                  2. to ignore a hideous trend.</span><!-- InstanceEndEditable --></td>
              </tr>
            </table></td>
        </tr>

        <tr>
          <td align="left" valign="bottom"><table width="100%" border="0" align="left" cellpadding="5" cellspacing="0">
              <tr> 
                <td> <div align="right" class="small"><a href="#top">Top of Page</a></div></td>
              </tr>
              <tr> 
                <td><div align="center" class="small"><a href="../index.php">Ask 
                    Priscilla Home </a>| <a href="ask_priscilla.php">Ask 
                    Priscilla! </a> | <a href="ask_news.php">News 
                    &amp; Views</a> | <a href="book_samplings.php">Read 
                    the Book!</a> | <a href="priscilla_book.php">Book 
                    Reviews </a> | <a href="author_bio.php">About 
                    Priscilla</a> | <a href="contact.php">Contact 
                    Priscilla</a><br>
                    &copy; 2004 Priscilla Kohutek. All Rights Reserved.</div></td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
<map name="Map">
  <area shape="rect" coords="25,85,127,94" href="http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?userid=ZYw1F6Dw0Z&isbn=1890206210&itm=1" target="_blank">
  <area shape="rect" coords="100,61,129,70" href="buy_book.php">
</map>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-1400200-1";
urchinTracker();
</script>
</BODY>
<!-- InstanceEnd --></HTML>

what exactly is wrong with the text when its displayed on the page?

what exactly is wrong with the text when its displayed on the page?

In places where there is supposed to be a comma or a an apostraphie there are the wrong characters. Take a look at the second line. There is supposed to be a comma after abuse and an apostraphie in that's.

i have never seen this before when i input commas and apostrophes but maybe this will help. Since you are having problems, replace the commas in the database text with the special html code

commas:

&#44

and apostrophes:

&#146

make sure you add an ; to the end of both of those. the code tags didn't work for the special html code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.