problem with single quote in postgres 8.3.5

From: hugocoolens <hugocoolens(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: problem with single quote in postgres 8.3.5
Date: 2009-03-07 13:53:21
Message-ID: 04681d71-fe95-4205-9488-3e1c2b0ceb32@j38g2000yqa.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a little php-script to help me learn foreign languages
In my php-code I have the following line:
$query="update wordlist set known=true where dutch='".$preceding."'";

This worked fine on a system running postgres 8.1, however in version
8.3.5 something changed which makes records with the dutch-field
containing single quotes unfindable. You could argue that it's a bad
practice to include records with single quotes in a field but in
language related applications it's unavoidable as single quotes are
used and escaping every single quote when adding data to the database
is something you can't ask the user.

example of a dutch field which causes the problem: hij zei: 'het is
waar'

I guess there must be a way to escape the single quotes automatically
without rebuilding the database

any help appreciated

hugo

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Devrim GÜNDÜZ 2009-03-07 14:55:27 Re: Installing a module for PostgreSQL
Previous Message Stefan Kaltenbrunner 2009-03-07 10:58:43 Re: Postgres Cookbook