Re: Problem with inserting newlines and ' characters

From: Kyle <kaf(at)nwlink(dot)com>
To: Alan Horn <ahorn(at)inktomi(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Problem with inserting newlines and ' characters
Date: 2000-07-24 16:48:35
Message-ID: 14716.29539.806840.987556@ip146.usw5.rb1.bel.nwlink.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alan Horn wrote:
...
> The statement I'm using is thus :
>
> my($sth) = $dbh->prepare("insert into maintenance (sno, date, data) values
> ('$sno', '$date', '$tmpstring')");
>
> (all on one line of course...)
>
> My problem is this. $tmpstring may well contain embedded newlines or '
> characters (these are the two characters I've had problems with so far).
...

The method you're looking for is $dbh->quote. You could use it like:

$sth = $dbh->prepare("insert into maintenance (sno, date, data)
values ($dbh->quote($sno),
$dbh->quote($date),
$dbh->quote($tmpstring))");

Hope that helps.

Regards,
Kyle

In response to

Browse pgsql-general by date

  From Date Subject
Next Message davidb 2000-07-24 17:29:23 Re: PostgreSQL, ODBC, Access
Previous Message Tom Lane 2000-07-24 16:43:14 Re: Multithreaded libpq?