 |
|
 |
|
Next: Oracle OIM (Oracle Identity Manager )--Hightstown..
|
| Author |
Message |
External

Since: Sep 24, 2010 Posts: 2
|
(Msg. 1) Posted: Fri Sep 24, 2010 5:25 am
Post subject: special character into descrition field Archived from groups: comp>databases>mysql (more info?)
|
|
|
Hi all,
in order to manage the special character into descrition field (i.e.:
"Description 1, sddsd'")
the sql query returns an error about ' character. I have correct this query with
this description : "Description 1, sddsd\'". It's the right way ? can i do better ?
many thanks.
Onorato. >> Stay informed about: special character into descrition field |
|
| Back to top |
|
 |  |
External

Since: Jan 14, 2008 Posts: 245
|
(Msg. 2) Posted: Fri Sep 24, 2010 5:25 am
Post subject: Re: special character ' [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On 24 Sep, 09:52, softwareEngineer wrote:
> Hi all,
> in order to manage the special character into descrition field (i.e.:
> "Description 1, sddsd'")
> the sql query returns an error about ' character. I have correct this query with
> this description : "Description 1, sddsd\'". It's the right way ? can i do better ?
>
> many thanks.
>
> Onorato.
Who can tell?
You haven't shown us the query.
You haven't shown us the error message. >> Stay informed about: special character into descrition field |
|
| Back to top |
|
 |  |
External

Since: Apr 11, 2008 Posts: 1021
|
(Msg. 3) Posted: Fri Sep 24, 2010 7:25 am
Post subject: Re: special character ' [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
El 24/09/2010 10:52, softwareEngineer escribió/wrote:
> Hi all,
> in order to manage the special character into descrition field (i.e.:
> "Description 1, sddsd'")
> the sql query returns an error about ' character. I have correct this
> query with
> this description : "Description 1, sddsd\'". It's the right way ? can i
> do better ?
If it's a query you're writing manually, it's just fine: that's the
syntax to escape special chars.
However, if the query is being fed automatically by a program, you
should use a better method than escaping charactered one by one.
Whatever language and library you are using, it sure has an escaping
mechanism, either quote functions or prepared statements.
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
-- >> Stay informed about: special character into descrition field |
|
| Back to top |
|
 |  |
External

Since: Sep 24, 2010 Posts: 2
|
(Msg. 4) Posted: Fri Sep 24, 2010 12:25 pm
Post subject: Re: special character ' [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
The query is :
--> INSERT INTO device SET id = 26, configuration = 14, communication = 40,
description = 'SCORZE' 297';
It is generated by automated process written in c (through mySQL c api).
which is the correct way to handle this type of situations ? now, via code, i
replace into the "description"
string the ' char with \' . but IT'S ok ? is it ANSI SQL ?
many thanks.
Il 24/09/2010 11.19, Captain Paralytic ha scritto:
> On 24 Sep, 09:52, softwareEngineer wrote:
>> Hi all,
>> in order to manage the special character into descrition field (i.e.:
>> "Description 1, sddsd'")
>> the sql query returns an error about ' character. I have correct this query with
>> this description : "Description 1, sddsd\'". It's the right way ? can i do better ?
>>
>> many thanks.
>>
>> Onorato.
> Who can tell?
>
> You haven't shown us the query.
>
> You haven't shown us the error message. >> Stay informed about: special character into descrition field |
|
| Back to top |
|
 |  |
External

Since: Aug 11, 2004 Posts: 3780
|
(Msg. 5) Posted: Fri Sep 24, 2010 1:17 pm
Post subject: Re: special character ' [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On 9/24/2010 11:37 AM, softwareEngineer wrote:
> Il 24/09/2010 11.19, Captain Paralytic ha scritto:
>> On 24 Sep, 09:52, softwareEngineer wrote:
>>> Hi all,
>>> in order to manage the special character into descrition field (i.e.:
>>> "Description 1, sddsd'")
>>> the sql query returns an error about ' character. I have correct this
>>> query with
>>> this description : "Description 1, sddsd\'". It's the right way ? can
>>> i do better ?
>>>
>>> many thanks.
>>>
>>> Onorato.
>> Who can tell?
>>
>> You haven't shown us the query.
>>
>> You haven't shown us the error message.
>
>
> The query is :
>
> --> INSERT INTO device SET id = 26, configuration = 14, communication =
> 40, description = 'SCORZE' 297';
>
> It is generated by automated process written in c (through mySQL c
> api).
>
> which is the correct way to handle this type of situations ? now, via
> code, i replace into the "description"
> string the ' char with \' . but IT'S ok ? is it ANSI SQL ?
>
> many thanks.
>
>
<top posting fixed>
Look at mysql_real_escape_string() - that's what it's there for, and
it's a lot safer than just using a "\'" - i.e. it's charset aware and
will catch ALL the potential problems in the current charset.
P.S. Please don't to post. Thanks.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex DeleteThis @attglobal.net
================== >> Stay informed about: special character into descrition field |
|
| Back to top |
|
 |  |
External

Since: Apr 26, 2010 Posts: 22
|
(Msg. 6) Posted: Fri Sep 24, 2010 5:25 pm
Post subject: Re: special character ' [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On 2010-09-24 17:37, softwareEngineer wrote:
>
> The query is :
>
> --> INSERT INTO device SET id = 26, configuration = 14, communication = 40,
> description = 'SCORZE' 297';
>
> It is generated by automated process written in c (through mySQL c api).
>
> which is the correct way to handle this type of situations ? now, via code, i
> replace into the "description"
> string the ' char with \' . but IT'S ok ? is it ANSI SQL ?
>
ANSI SQL is:
... description = 'SCORZE'' 297'
As others have mentioned in this thread, there are functions in your
host language that can handle this.
/Lennart
[...] >> Stay informed about: special character into descrition field |
|
| Back to top |
|
 |  |
| Related Topics: | Best way to issue hundreds of inserts/updates??? - Using mysql 4.0.23- What is the best way to execute several (hundreds of) inserts and updates? Rather than issuing tons of individual inserts and updates, can I send the strings to a text file and then have mysql do them all?? IE : query.txt insert..
MySQL freezes, brings XP machine to a grinding halt - I've been using MySQL for a while for fairly light database development on my XP machine. Currently, I am just starting a new project and have experienced some big problems with MySQL today both on my office machine and at home where running a particular...
login as user 'root' but do not have root privlages and my.. - Hi gang: I'm experiencing a problem with MySQL -- I updated MySQL from version 4.1.0 to 4.1.10 and now when I login as root it doesn't show all the databases I should have access to, nor it doesn't recognize me being logged in as root (via..
FLUSH TABLES hangs if table is locked - Using FLUSH TABLES via the C query API mysql_query() hangs if the table is locked already. That is to say, nothing prevents me from running a LOCK TABLES twice; it won't tell me "it's already locked, don't try to run a FLUSH". Anyone know ...
Tool to convert DDL in graphical diagram? - Does anyone know of a tool that will create a graphical diagram from a DDL (SQL create script)? Preferable a free open-source tool. Thanks, A |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|