Dealing with commas in fields
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.
--
Regards,
M. Tessier
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.