Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: single quotes and perl
Date: Jan 12 2001 5:22PM

Tanja Davidson writes:
 > I've got a newbie perl programmer question.
 > I've been using sybase::Ctlib to do my database connections and all has
 > gone fine until I realized that there's a problem with single quotes if
 > they exist in the text fields of my web forms.
 > Can anyone give me a work around for inserting and searching on text
 > variables which may have embedded single quotes?  
 > The docs I've found so far have said to $var=~s/'/''/g but that ends up
 > inserting two single quotes into my database which is unacceptable.

It shouln't insert two single quotes:

[24] SYBASE.testdb: 1> insert bcp_test values('o''conor', "she ""said"" ")
[24] SYBASE.testdb: 2> go
(1 row affected)
[25] SYBASE.testdb: 1> select * from bcp_test
[25] SYBASE.testdb: 2> go
 a          b         
 ---------- ----------
 o'conor    she "said"

Anyway - you should be able to double the single quotes and have it
work correctly. If it doesn't then I'd like to see the code - there
must be something else that's wrong with it.

Michael Peppler - Data Migrations Inc. - -
International Sybase User Group -
Sybase on Linux mailing list: