473,395 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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_gpc = on
magic_quotes_runtime = off
magic_quotes_sybase = 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($_POST['frmOldPhrase'],
$_POST['frmNewPhrase'], $srRow['content'], $contentCount);
$newTitle = str_replace($_POST['frmOldPhrase'], $_POST['frmNewPhrase'],
$srRow[$title], $titleCount);

$sqlUpdateFields = '';

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

$srUpdateSql = "UPDATE ".$table." SET ".$sqlUpdateFields." 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 1811
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_gpc = on
magic_quotes_runtime = off
magic_quotes_sybase = 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($_POST['frmOldPhrase'],
$_POST['frmNewPhrase'], $srRow['content'], $contentCount);
$newTitle = str_replace($_POST['frmOldPhrase'], $_POST['frmNewPhrase'],
$srRow[$title], $titleCount);

$sqlUpdateFields = '';

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

$srUpdateSql = "UPDATE ".$table." SET ".$sqlUpdateFields." 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_escape_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*******@attglobal.net
==================
Oct 2 '06 #2

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

Similar topics

0
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 ©...
11
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
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...
19
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...
50
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...
40
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.,...
2
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...
3
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....
7
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
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...

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.