shane07 Posted July 29, 2009 Share Posted July 29, 2009 I have a table with a fieldname having a value with apostrophe character. e.g. 'Patient\'s Name' When executing the sql statement: select * from table where field='Patient\'s Name' or select * from table where field='Patient's Name' results empty row. For other values the sql works fine. Sometimes while inserting data, data is inserted in following format 'Patient’s Name'. I wonder how. I'm using same browser when inserting data. I'm inserting through php scripts. In this case the sql, select * from table where field='Patient’s Name' works fine. Can somebody get me out of this problem? Quote Link to comment Share on other sites More sharing options...
Zyx Posted July 29, 2009 Share Posted July 29, 2009 Could you show some PHP code that generates the query? The following query: select * from table where field='Patient\'s Name' will work, if your table contains a row with "Patient's Name" value in the field "field". The second query won't work, as it contains a syntax error. Quote Link to comment Share on other sites More sharing options...
aschk Posted July 29, 2009 Share Posted July 29, 2009 That apostrophe isn't part of the normal character set. it's most probably being pasted from a word document as something like a backtick (`). Thus your problem is that your database isn't storing your data as UTF-8. So I suggest your first port of call is to alter the table schema to UTF-8 first. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 3, 2009 Share Posted August 3, 2009 Or, run a sanitize script that converts these magic characters -- which often crop up when people C&P from Word -- into regular, ASCII characters. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.