Hello All,

I have declared one of my fields in the database as

PropertyName varchar(100);

Now the problem is that when I try to insert the text having an apostrophe using my html form it gives me an error.

Can you please help me with the issue as I am having loads of trouble due to this?

Many thanks.

Best regards,
Adi.

Hi Adi,

Use mysql_real_escap_string() to insert such data if you are using PHP.

Thats because, while inserting, you insert this way. insert into table (col1) values ('value'); But since your value already has a ', its considered as the end of value, throwing an error. If you are using php, you can escape ' or " by using mysql_real_escape_string or addslashes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.