473,796 Members | 2,434 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

html_entity_dec ode when reading from a database

69 New Member
Hi,

I'm trying to read the results of a database query into an XML document but it's only read so far and stopping. The XML document is as follows:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <night>
  4.  
  5.   <name>Poontang</name>
  6.  
  7.   <homePageSummary>Launches 26th November</homePageSummary>
  8.  
  9.   <whatsOnPageSummary>Every Monday from 26th Nov Door price: £5/£4 Guestlist (07809867930)</whatsOnPageSummary
  10.  
  11. >
  12.  
  13.   <description>Poontang is of course, a punch made from the fermented juice from the rare poonberry bush
  14.  
  15. . It became hugely popular during colonial times, it was a favourite of the Founding Fathers, drank constantly
  16.  
  17.  by George Washington, as evedenced by his farewell address, 'I only took the job for the poontang'.
  18.  
  19.  &lt;br /&gt;
  20.  
  21.  
  22. &lt;br /&gt;
  23.  
  24.  
  25. The first recorded recipe was printed in Ye Boston Globe. Unfortunately, poontang's immense popularity
  26.  
  27.  was later learned to be the result of addictive qualities. &lt;br /&gt;
  28.  
  29.  
  30. &lt;br /&gt;
  31.  
  32.  
  33. The hunger for good quality poontang is said to have made a Bishop kick a hole in a stained glass window
  34.  
  35. . Withdrawl will occur, leading to unappealing physical &amp;amp; mental consequences, including blue
  36.  
  37.  balls, hairy palms &amp;amp; lack of mental clarity. &lt;br /&gt;
  38.  
  39.  
  40. &lt;br /&gt;
  41.  
  42.  
  43. COME SEE THE POONTANG PANDA.... &lt;br /&gt;
  44.  
  45.  
  46. Performing its erotic pole dance routine &lt;br /&gt;
  47.  
  48.  
  49. Pouring free poontang punch from the stage &lt;br /&gt;
  50.  
  51.  
  52. Giveaway baby poontang panda cuddly toys &lt;br /&gt;
  53.  
  54.  
  55. and if your lucky he might just hump your leg! &lt;br /&gt;
  56.  
  57.  
  58. &lt;br /&gt;
  59.  
  60.  
  61. DRINKS &lt;br /&gt;
  62.  
  63.  
  64. Baby Champers 70p! &lt;br /&gt;
  65.  
  66.  
  67. Bottles of Sol &amp;amp; Sambucca Shots &amp;pound;1 &lt;br /&gt;
  68.  
  69.  
  70. Double Spirit &amp;amp; Mixer inc Red Bull &amp;pound;2.40 &lt;br /&gt;
  71.  
  72.  
  73. Poontang Pitchers &amp;amp; Red Pig Pithcers &amp;pound;5 &lt;br /&gt;
  74.  
  75.  
  76. Bottles of House Wine &amp;pound;7 &lt;br /&gt;
  77.  
  78.  
  79. &lt;br /&gt;
  80.  
  81.  
  82. MUSIC &lt;br /&gt;
  83.  
  84.  
  85. Big Panda Party Tunes -&amp;gt; Dance, R'n'B and Indie &lt;br /&gt;
  86.  
  87.  
  88. &lt;br /&gt;</description>
  89.  
  90.   <thumbnail>thumb447.jpg</thumbnail>
  91.  
  92.   <flyer>poon_flyer451.jpg</flyer>
  93.  
  94. </night>
  95.  
I'm using the following the try and sort out the entities.

Expand|Select|Wrap|Line Numbers
  1. function html_numeric_entities($str) 
  2.     return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); 
  3. }; 
  4.  
  5. $description = html_numeric_entities(html_entity_decode($row['description']));
  6. $description = $night->appendChild($dom->createElement('description', $description));
  7.  
But it's only getting so far. I've tried it with just html_entity_dec ode but it gets struck with ampersands and £ signs. So I be using htmlentities when writing to the database, along with addslashes and then html_entity_dec ode when reading from the database. I've also had problems with hyphens. The PHP code can create the database but the Javascript code that reads the XML document when I'm creating an Ajax.Request cannot.

Hopefully some kind soul can guide on what I'm doing wrong.

Thanks,

Sean
Nov 23 '07 #1
1 2132
pbmods
5,821 Recognized Expert Expert
Heya, Sean.

Instead of worrying about HTML entities, try using CDATA tags.
Nov 26 '07 #2

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

Similar topics

2
3081
by: HI-Lab * the Social Technology | last post by:
Is there another function or a workaround to have same results of html_entity_decode in php 4.1.x? Thanks. -- ======================================= HI-LAB the Social Technology °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° www.hi-lab.net
0
2064
by: lawrence | last post by:
Using the conversion to char sets described for these functions, is it possible to get a whole string into some charset? I'm trying to figure out a way to take invalid character sets from idiot users, and translate the string so that in the end I have a string that won't cause my XML to test invalid. html_entity_decode() htmlspecialchars() htmlentities()
10
7750
by: Markus Ernst | last post by:
Hi I have a string such as Добро" that shows the cyrillic word "?????" in the browser. Now I played around with lots of examples and contributed functions in the manual (html_entity_decode, strtr, convert_cyr_string ...) but was not able to decode these entities. As browsers displays them correctly on my PC and Mac
1
1851
by: sylvian stone | last post by:
Hi, I've been having problems encoding / decoding data, and can't seem to figure out where I am going wrong. I extract data from a mysql table with a line like: $object_name = stripslashes(htmlspecialchars($row, ENT_QUOTES));
3
4241
by: Koen | last post by:
Hi, first of all, the machine setup server 1: - UDB2 7.2.5; COUNTRY=1, location = US, IBM1250 codepage - Locale: US English; Regional Settings: English; Keyboard: Dutch; decimal separator: . server 2: - UDB2 7.2.5 Client Tools - Websphere 4.0.5
4
3817
by: jack turer | last post by:
I have a database in pgsql (7.3.2) on redhat 9. When I try a 'pg_dump mydb' to back up the database, I get: pg_dump: could not find namespace with OID 2200 Verbose version is: -bash-2.05b$ pg_dump -v mydb | more pg_dump: saving database definition pg_dump: reading namespaces pg_dump: reading user-defined types
6
4975
by: dgleeson3 | last post by:
Hello All I have VB code (.Net 2005) reading from an SQL server 2005 database. Im getting InvalidCastException when doing reader.GetInt32(0) Im simply reading an int from a simple database. It has two columns, User and Tel number. User is filled with 1,2,3 and tel number has 3 telephone numbers. The User data column is specified as (PK, int, not null) in MS SQL
9
4349
nathj
by: nathj | last post by:
Hi, As you can tell by the subject of this post I'm having a spot of bother with htmlentities() and html_entity_decode(). I have built/am building a web site that allows user feedback. When the user enters their review of a resource it is stored in the database. It goes into a LONGTEXT field and what is entered is passed through htmlentities(): $reviewToStore = htmlentities($reviewEntered, ENT_QUOTES) ; The results in the database...
1
7114
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that someone who bothers to read all of it have some pointers. Note, I have posted the stack trace and the code exhibiting the problem further down so if you want to start by reading that, search for +++ Also note that I am unable to reproduce...
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10455
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10006
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7547
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.