Received: from giasdl01.vsnl.net.in (giasdl01.vsnl.net.in [202.54.15.1]) by hub.org (8.9.1/8.9.1) with ESMTP id UAA20303 for ; Tue, 1 Dec 1998 20:42:07 -0500 (EST) (envelope-from srswamy@giasdl01.vsnl.net.in) Received: from del1.vsnl.net.in (d311.pppdel.vsnl.net.in [202.54.14.11]) by giasdl01.vsnl.net.in (8.8.8/8.8.8) with ESMTP id HAA00464; Wed, 2 Dec 1998 07:12:01 +0500 (GMT+0500) Message-ID: <3663B3F4.5360F306@del1.vsnl.net.in> Date: Tue, 01 Dec 1998 14:46:36 +0530 From: "S.Ramaswamy" Organization: Matrix Infotech Syndicate X-Mailer: Mozilla 4.04 [en] (Win95; I) MIME-Version: 1.0 To: PETER PAULY CC: pgsql-sql@postgreSQL.org Subject: Re: [SQL] Odd characters in inserted data... References: <19981129222947.29657.qmail@www0n.netaddress.usa.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit PETER PAULY wrote: > I'm using the "C" interface to write CGI code for a web application. I allow > the user to type data into a particular field, and am storing that data into a > field in a postgres database. > > The problem is, I have to filter the data that the user entered to remove any > single quotes and other odd characters so that my SQL command doesn't get > messed up. I'm building the command with printf and passing the filtered > data from the user as so: > > update tablename set comment = '%s' where ..... > > And %s is substituted in the printf with the user data. If the user typed in a > single quote, it would cause havoc with the sql statement. My question is, is you should substitute single quote with two single quotes > there a better way to pass data to these commands, than to build a command > string like you see above? My preference would be to pass a pointer to the > data, or something like that. (same issue with insert). > > ____________________________________________________________________ > Get free e-mail and a permanent address at http://www.netaddress.com/?N=1 -- ___________________________________________________________________________ S.Ramaswamy Matrix Infotech Syndicate D-7, Poorti, Vikaspuri, New Delhi, 110018, India PHONE: +91-11-5610050, FAX: +91-11-5535103 WEB : http://MatrixInfotech.HyperMart.Net