views:

129

answers:

1

For my forms, I'm using pg_escape_string on every field before I insert them into the database. So I get something like firstname='O''reilly'. But when I try to print that out, I get O''reily, 2 apostrophes. Shouldn't it only 1 apostrophe, O'reilly?

This isnt a debugging problem, im just wondering if you have firstname='O''reilly', how do you print that so it is just O'reilly instead of O''reilly?

A: 

DB libraries usually don't (or never) have an unescape function because there's no real need to do this. The DB will store and return the data unescaped. Plus, since you're calling the function, that means you already have the data in unescaped form.

However, you could remove double apostrophes from a string with a simple call to str_replace:

echo str_replace("''", "'", "O''reilly");
webbiedave