473,573 Members | 2,950 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 2118
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
3073
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
2053
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()...
10
7706
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
1837
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
4214
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
3803
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
4965
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...
9
4329
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...
1
7090
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...
0
7771
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...
0
7686
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7771
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8060
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...
1
5580
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...
0
3730
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...
0
3731
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2194
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1296
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.