PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
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
-- 
Michael Peppler - Data Migrations Inc. - mpeppler@peppler.org
http://www.mbay.net/~mpeppler - mpeppler@mbay.net
International Sybase User Group - http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com