944,117 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 957
  • PHP RSS
Sep 25th, 2007
0

PHP Apostrophes Problem

Expand Post »
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

PHP Syntax (Toggle Plain Text)
  1.  
  2. <?
  3.  
  4. include_once('./db.php');
  5.  
  6. function Get_Nix()
  7. {
  8. $sql = "SELECT * FROM nix WHERE position IS NOT null ORDER BY position ASC LIMIT 1";
  9. $result = mysql_query($sql);
  10. $numRows = mysql_num_rows($result);
  11. if($numRows == 0)
  12. {
  13. echo "Sorry, no nixit is available this month.";
  14. }
  15. else
  16. {
  17. while($row = mysql_fetch_assoc($result))
  18. {
  19. extract($row);
  20. $nix = nl2br($nix);
  21. ?>
  22.  
  23. <p class="small"><?
  24. echo $title."<br><br>";
  25. echo $nix."&nbsp;&nbsp;<img src=\"../images/house.gif\" border=\"0\">";
  26.  
  27. ?></p>
  28.  
  29. <?
  30. }
  31. }
  32. }
  33.  
  34. function Get_TAT()
  35. {
  36. $sql = "SELECT * FROM tip WHERE position IS NOT null ORDER BY position ASC LIMIT 2";
  37. $result = mysql_query($sql);
  38. $numRows = mysql_num_rows($result);
  39. if($numRows == 0)
  40. {
  41. #echo "Sorry, no departments were found.";
  42. }
  43. else
  44. {
  45. while($row = mysql_fetch_assoc($result))
  46. {
  47. extract($row);
  48. $tip = nl2br($tip);
  49. ?>
  50. <p class="bodystyle"><? echo $title."<br><br>";
  51. echo $tip."&nbsp;&nbsp;<img src=\"../images/house.gif\" border=\"0\">" ?></p><br><br>
  52.  
  53. <?
  54. }
  55. }
  56. }
  57. ?>
  58.  
  59.  
  60. <HTML><!-- InstanceBegin template="/Templates/inside.dwt.php" codeOutsideHTMLIsLocked="false" -->
  61. <HEAD>
  62. <!-- InstanceBeginEditable name="doctitle" -->
  63. <TITLE>Ask Priscilla</TITLE>
  64. <!-- InstanceEndEditable -->
  65. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
  66. <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
  67. <script language="JavaScript" type="text/JavaScript">
  68. <!--
  69. function MM_preloadImages() { //v3.0
  70. var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  71. var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  72. if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  73. }
  74.  
  75. function MM_swapImgRestore() { //v3.0
  76. var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  77. }
  78.  
  79. function MM_findObj(n, d) { //v4.01
  80. var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  81. d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  82. if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  83. for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  84. if(!x && d.getElementById) x=d.getElementById(n); return x;
  85. }
  86.  
  87. function MM_swapImage() { //v3.0
  88. var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  89. if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  90. }
  91. //-->
  92. </script>
  93. <link href="../main.css" rel="stylesheet" type="text/css">
  94. </HEAD>
  95.  
  96. <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')">
  97. <a name="top"></a>
  98. <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
  99. <tr>
  100. <td align="left" valign="top" height="5"><table width="100%" height="99" border="0" cellpadding="0" cellspacing="0">
  101. <tr bgcolor="0A4903">
  102. <td align="left"><IMG SRC="../images/top_bar_priscilla.jpg" ALT="" WIDTH=138 HEIGHT=99 border="0"></td>
  103. <td align="center"><a href="../index.php"><IMG SRC="../images/top_bar_ask.gif" ALT="" WIDTH=305 HEIGHT=99 border="0"></a></td>
  104. <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>
  105. </tr>
  106. </table></td>
  107. </tr>
  108. <tr>
  109. <td align="left" valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  110. <tr>
  111. <td width="131" rowspan="3" align="left" valign="top" background="../images/inside_shading.jpg">
  112. <TABLE WIDTH=131 BORDER=0 CELLPADDING=0 CELLSPACING=0>
  113. <TR>
  114. <TD width="131" background="../images/inside_shading.jpg">
  115. <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>
  116. </TR>
  117. <TR>
  118. <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>
  119. </TR>
  120. <TR>
  121. <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>
  122. </TR>
  123. <TR>
  124. <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>
  125. </TR>
  126. <TR>
  127. <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>
  128. </TR>
  129. <TR>
  130. <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>
  131. </TR>
  132. <TR>
  133. <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>
  134. </TR>
  135. </TABLE></td>
  136. <td align="left" valign="top" background="../images/inside_shading.jpg"><table width="475" height="100%" border="0" align="left" cellpadding="0" cellspacing="10">
  137. <tr>
  138. <td align="left" valign="top" class="bodystyle"><!-- InstanceBeginEditable name="main body" -->
  139. <img src="../images/head_news.gif" border="0"> <br>
  140. <? Get_TAT(); ?>
  141. <!-- InstanceEndEditable --> </td>
  142. </tr>
  143. </table> </td>
  144. <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>
  145. <table width="200" border="0" align="right" cellpadding="0" cellspacing="10" class="sidebar">
  146. <tr>
  147. <td align="left" valign="top"><!-- InstanceBeginEditable name="sidebar" -->
  148. <img src="../images/head_nixit.gif" width="92" height="36" border="0"><br>
  149. <? Get_Nix(); ?>
  150. <br>
  151. <br>
  152. <br>
  153. <hr size="1" noshade>
  154. <span class="small"><strong>* Nix&middot;it (nicks &middot;
  155. it) v.</strong><br>
  156. 1. to do away with, especially when it comes to home decorating.<br>
  157. 2. to ignore a hideous trend.</span><!-- InstanceEndEditable --></td>
  158. </tr>
  159. </table></td>
  160. </tr>
  161.  
  162. <tr>
  163. <td align="left" valign="bottom"><table width="100%" border="0" align="left" cellpadding="5" cellspacing="0">
  164. <tr>
  165. <td> <div align="right" class="small"><a href="#top">Top of Page</a></div></td>
  166. </tr>
  167. <tr>
  168. <td><div align="center" class="small"><a href="../index.php">Ask
  169. Priscilla Home </a>| <a href="ask_priscilla.php">Ask
  170. Priscilla! </a> | <a href="ask_news.php">News
  171. &amp; Views</a> | <a href="book_samplings.php">Read
  172. the Book!</a> | <a href="priscilla_book.php">Book
  173. Reviews </a> | <a href="author_bio.php">About
  174. Priscilla</a> | <a href="contact.php">Contact
  175. Priscilla</a><br>
  176. &copy; 2004 Priscilla Kohutek. All Rights Reserved.</div></td>
  177. </tr>
  178. </table></td>
  179. </tr>
  180. </table></td>
  181. </tr>
  182. </table>
  183. <map name="Map">
  184. <area shape="rect" coords="25,85,127,94" href="http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?userid=ZYw1F6Dw0Z&isbn=1890206210&itm=1" target="_blank">
  185. <area shape="rect" coords="100,61,129,70" href="buy_book.php">
  186. </map>
  187. <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
  188. </script>
  189. <script type="text/javascript">
  190. _uacct = "UA-1400200-1";
  191. urchinTracker();
  192. </script>
  193. </BODY>
  194. <!-- InstanceEnd --></HTML>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Unverified User
jonathan.jbkt is offline Offline
29 posts
since Dec 2006
Sep 25th, 2007
0

Re: PHP Apostrophes Problem

what exactly is wrong with the text when its displayed on the page?
Last edited by kkeith29; Sep 25th, 2007 at 6:25 pm.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Sep 25th, 2007
0

Re: PHP Apostrophes Problem

Quote ...
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.
Reputation Points: 10
Solved Threads: 0
Unverified User
jonathan.jbkt is offline Offline
29 posts
since Dec 2006
Sep 25th, 2007
0

Re: PHP Apostrophes Problem

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:

PHP Syntax (Toggle Plain Text)
  1. &#44

and apostrophes:

PHP Syntax (Toggle Plain Text)
  1. &#146

make sure you add an ; to the end of both of those. the code tags didn't work for the special html code.
Last edited by kkeith29; Sep 25th, 2007 at 6:48 pm.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: which php local server is good.
Next Thread in PHP Forum Timeline: Using URL to display items on page????





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC