MySQL error when inserting data containing apostrophes (single quotes)?

前端 未结 10 1095
不知归路
不知归路 2020-11-30 13:59

When I an insert query contains a quote (e.g. Kellog\'s), it fails to insert a record.

ERROR MSG:

You have an error in your SQL s

10条回答
  •  悲哀的现实
    2020-11-30 14:16

    You can also use the addslashes() function which automatically puts \ before ' to avoid error

提交回复
热议问题