473,605 Members | 2,637 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Searching and Replacing Character Entities

I have been using TinyMCE as a WYSIWYG editor for getting content into
a database and then exporting that data into an XML format to redender
in flash using CDATA. The problem is that I didn't realize that Flash
has a problem with character entities such as ' ” and a few
others. I need to search and replace these but I keep on getting a SQL
error.

I get this error:::
Query failed: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to
use near 's Web site and landing...', content = 'Check customer\'s Web
site and' at line 3

My update SQL command is simple:
UPDATE theTableName
SET content = 'the new content to be inserted'
WHERE id = '22'

My PHP config on the server is (i just thought to take a look at how
the server was set up):
magic_quotes_gp c = on
magic_quotes_ru ntime = off
magic_quotes_sy base = off

I echo'ed out the query and I still can't see the problem. The only
thing that I can think of is that the content has " in it and I'm doing
a search and replace on it's character entity ” to change it to
the literal " but it ends up escaping those " to \" and it might end up
causing a problem in SQL. But see that sounds stupid to me so I'm not
too confident with that reasoning.

Here's the code in context as to what I'm doing currently
$newContent = str_replace($_P OST['frmOldPhrase'],
$_POST['frmNewPhrase'], $srRow['content'], $contentCount);
$newTitle = str_replace($_P OST['frmOldPhrase'], $_POST['frmNewPhrase'],
$srRow[$title], $titleCount);

$sqlUpdateField s = '';

if( $contentCount 0 )
{
$sqlUpdateField s .= "content = '".$newContent. "'";
}
if( $sqlUpdateField s != '' )
{
$sqlUpdateField s .= ", ";
}
if( $titleCount 0 )
{
$sqlUpdateField s .= "title = '".$newTitle."' ";
}

$srUpdateSql = "UPDATE ".$table." SET ".$sqlUpdateFie lds." WHERE id =
'".$srRow['id']."'";

That's the code I'm using. I'm stumped here. I tried addslashes()
around my content and that just added like 4 slashes because it was
escaping the already added slashes from having majic quotes on.

What am I doing wrong here??

Oct 2 '06 #1
1 1822
Tony wrote:
I have been using TinyMCE as a WYSIWYG editor for getting content into
a database and then exporting that data into an XML format to redender
in flash using CDATA. The problem is that I didn't realize that Flash
has a problem with character entities such as ' ” and a few
others. I need to search and replace these but I keep on getting a SQL
error.

I get this error:::
Query failed: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to
use near 's Web site and landing...', content = 'Check customer\'s Web
site and' at line 3

My update SQL command is simple:
UPDATE theTableName
SET content = 'the new content to be inserted'
WHERE id = '22'

My PHP config on the server is (i just thought to take a look at how
the server was set up):
magic_quotes_gp c = on
magic_quotes_ru ntime = off
magic_quotes_sy base = off

I echo'ed out the query and I still can't see the problem. The only
thing that I can think of is that the content has " in it and I'm doing
a search and replace on it's character entity ” to change it to
the literal " but it ends up escaping those " to \" and it might end up
causing a problem in SQL. But see that sounds stupid to me so I'm not
too confident with that reasoning.

Here's the code in context as to what I'm doing currently
$newContent = str_replace($_P OST['frmOldPhrase'],
$_POST['frmNewPhrase'], $srRow['content'], $contentCount);
$newTitle = str_replace($_P OST['frmOldPhrase'], $_POST['frmNewPhrase'],
$srRow[$title], $titleCount);

$sqlUpdateField s = '';

if( $contentCount 0 )
{
$sqlUpdateField s .= "content = '".$newContent. "'";
}
if( $sqlUpdateField s != '' )
{
$sqlUpdateField s .= ", ";
}
if( $titleCount 0 )
{
$sqlUpdateField s .= "title = '".$newTitle."' ";
}

$srUpdateSql = "UPDATE ".$table." SET ".$sqlUpdateFie lds." WHERE id =
'".$srRow['id']."'";

That's the code I'm using. I'm stumped here. I tried addslashes()
around my content and that just added like 4 slashes because it was
escaping the already added slashes from having majic quotes on.

What am I doing wrong here??
First of all, you should use mysql_real_esca pe_string() instead of
addslashes() to prepare your statement for inserting.

Then echo your statement before you insert it and post the entire output
of the echo (not some dummy data - it's important) here.

P.S. - is your id a numeric field? If so, you should not have quotes
around '22'. But that isn't where the message is pointing. You have
another problem.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Oct 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1820
by: Rutger Claes | last post by:
How do I stop the SAX parser from replacing entities such as ã and ©. When I use > and a default_handler, the default_handler is called and I can just print the data. Entities as © just get replaced by there symbol, something I don't want. Is there an option (or other solution) that disables this replacing. Rutger Claes --
11
2203
by: Albretch | last post by:
Hi HTML gurus, I understand that you would use HTML character entities for ä and € but why on earth would anyone encode: a colon: ":", a semicolon ";", or a gramatical period "." ?
76
15095
by: Zenobia | last post by:
How do I display character 151 (long hyphen) in XHTML (utf-8) ? Is there another character that will substitute? The W3C validation parser, http://validator.w3.org, tells me that this character and the ones around it are illegal - then, after resubmission it flags no errors. So, are there any illegal characters between 0 and 255 in the UTF-8 character set or is it just my imagination that the W3C validation parser thinks there are -...
19
3385
by: Ian | last post by:
I'm using the following meta tag with my documents: <meta http-equiv="Content-Type" content= "text/html; charset=us-ascii" /> and yet using character entities like &rsquo; and &mdash; It validates at W3C and WDG, and runs in standards compliance mode in Firefox 0.9. What I'm wondering is, is this a good practice? I assume my pages will load faster if declared as using the
50
4320
by: The Bicycling Guitarist | last post by:
A browser conforming to HTML 4.0 is required to recognize &#number; notations. If I use XHTML 1.0 and charset UTF-8 though, does &eacute; have as much support as é ? Sometimes when I run the TIDY utility on my code, it replaces my character notations with weird looking things I don't recognize. Also, when I converted to UTF-8 from ISO-8859-1, I discovered many special characters
40
3094
by: Shmuel (Seymour J.) Metz | last post by:
I'd like to include some Hebrew names in a web page. HTML 4 doesn't appear to include character attributes for ISO-8859-8. I'd prefer avoiding numeric references, e.g., "&#x05E9;&#x05DE;&#x05D5;&#x05D0;&#x05DC;". Is there currently a standardized set of character attributes for Hebrew? If so, is there a downloadable set of definitions for those attributes? Thanks. --
2
5568
by: Diilb | last post by:
I am using DOM to create an rss feed. The problem I am running into is "special characters" such as é è ç. If I try adding them to the XML as character data (CData), DOM chokes and throws out errors. If I do a search and replace on the characters changing them to HTML entities instead of using CDATA, DOM chokes up again. If I do a combination of both (search and replace then add as Character Data) it does not choke, but the RSS...
3
2060
by: bsagert | last post by:
Some web feeds use decimal character entities that seem to confuse Python (or me). For example, the string "doesn't" may be coded as "doesn’t" which should produce a right leaning apostrophe. Python hates decimal entities beyond 128 so it chokes unless you do something like string.encode('utf-8'). Even then, what should have been a right-leaning apostrophe ends up as "’". The following script does just that. Look for the string "The...
7
2553
by: tempest | last post by:
Hi all. This is a rather long posting but I have some questions concerning the usage of character entities in XML documents and PCI security compliance. The company I work for is using a third party ecommerce service for hosting its online store. A few months ago this third party commerce site began using PGP file encryption on XML files (e.g. web orders) transferred to us as part of the ongoing PCI security compliance.
0
8004
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
8425
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
8418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
5886
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
5445
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
3912
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
3958
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2438
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
0
1271
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.