1

How do I insert a value in MySQL that consist of single or double quotes. i.e

Ali said, "This is Ashok's Pen." 

The single quote will create problems. There might be other escape characters.

I am using php to enter data into the database?

How do you insert the data properly?

Abrar Ahmed
  • 124
  • 1
  • 3
  • 14

2 Answers2

2

You need to use \ (Escape) character to insert single quotes and double quotes.

INSERT INTO table_name(`clomn1`) VALUES ('Ali said, "This is Ashok\'s Pen."')
Dharman
  • 30,962
  • 25
  • 85
  • 135
Subin Chalil
  • 3,531
  • 2
  • 24
  • 38
1

Use mysqli_real_escape_string() mysqli_real_escape_string

Sanjay Kumar N S
  • 4,653
  • 4
  • 23
  • 38