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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.