Re: Dealing with commas in fields

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: MT <mt(at)open2web(dot)com>
Cc: Pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Dealing with commas in fields
Date: 2003-08-04 15:30:38
Message-ID: Pine.LNX.4.33.0308040927350.10306-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 1 Aug 2003, MT wrote:

> Hi,
>
> I'm using Postgresql to store customer and product information. Since
> this is a French language database, some of the names include commas.
> Information entered into this database is via html forms and php
> scripts.
> When I search the database with a partial name that includes a comma,
> such as D'Abcd, the database takes longer to find the record I'm looking
> for than if I searched the database with a partial name that does not
> include a comma, such as Abcd. I' ve also noticed if I D'Abcd in a php
> variable, which is diplayed as the title in the html header, it shows up
> as D\\\'Abcd, if this variable is passed and displayed in the next page,
> it shows up as d\\\\\\\\'Abcd.
>
> Is there a way to enter names with a comma into a field without it
> causing this strange behavior.

This "normal" PHP behaviour with most default installs. You need to
figure out where in your script you need to add stripslashes and
addslashes to your data. note that with postgresql, there are specific
functions you should use pg_escape_string, but this function requires
postgresql 7.2 or later, so if you're still on 7.1 you'll need to use
addslashes.

Use stripslashes to unescape the data when it comes back out.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message scott.marlowe 2003-08-04 15:37:25 Re: plPHP -- sort of an announcement.. but not commercial
Previous Message Bruce Momjian 2003-08-04 15:28:37 Re: Is there any place to get 7.4 win binaries ?