Jump to content

apostrophe problem


shane07

Recommended Posts

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?

 

Link to comment
https://forums.phpfreaks.com/topic/167916-apostrophe-problem/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/167916-apostrophe-problem/#findComment-885698
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/167916-apostrophe-problem/#findComment-885912
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.