Results 1 to 5 of 5
Dec 13, 2008, 20:36 #1
Postgres and characters from MSWord causing problems on insert/update
Okay, I have a client that has been running a web application on a codebase for a couple of years without any kind of problems.
This site is created in PHP, Smarty Templates, ADODB and a Postgres database.
I have started to receive a number of help requests from them because of errors that are now popping up in regarding to people trying to insert data into the database via the forms on the website.
Here is a sample sentence that is causing an error:
'The Jury Clerk is responsible for the work of the District Clerk’s Office in connection with qualifying, managing, and paying jurors for service.'
Now, I know tha tthe problem is with the apostrophe in the word 'Clerks'.
Here is our insert statement:
$sql = "INSERT INTO table_name (col1, col2, col3) VALUES (?,?,?)";
$db->Execute($sql, array($var1, $var2, $var3)) or die("Error in query: $sql. " . $db->ErrorMsg());
Okay, this has never been a problem until we found out that people were using Microsoft Word 2007 to create the text that they were going to enter into the website and then copy and paste it into the web form.
Can anyone shed light on why if I manually type this information into the form, the form works as expected, but if I copy it from Word 2007 - it fails?
Dec 14, 2008, 05:57 #2
- Join Date
- Aug 2007
- 0 Post(s)
- 0 Thread(s)
Because even it's it looks similar, Word don't use Ascii characters.
I suspect that it uses an utf-8 charset, and that your DB collation is set to ascii.
Here is an ascii character table, if needed:
If you try to dump your form values with an ord(character), you will see that the ascii value is different of the regular single quote.
In the past, I finished with a "cleanup" function that was replacing those characters with their equivalent in ascii.
Dec 14, 2008, 08:21 #3
What was strange to me is that it was only happening in Word2007 characters and not others.
But your answer did push me in the right direction and I was able to get a solution in place.
Dec 15, 2008, 07:10 #4
- Join Date
- Feb 2004
- Tampa, FL (US)
- 1 Post(s)
- 0 Thread(s)
Dec 15, 2008, 07:27 #5
Sorry if I was clear about the problem.
End users were copying and pasting from Word - I was not trying to code the site or anything in Word - I'm not that stupid.
Maybe you should read the thread that a solution was found and that we didn't your idiotic, 'better than you' answer.