开发者

Handling apostrophes, php and pgsql

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 s开发者_开发百科o it is just O'reilly instead of O''reilly?


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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜