0

I have written a simple sql as:

$query = "INSERT INTO `pre` (`word`, `description`, `status`) VALUES (`$word`, `$desc`, `$status`)";

and I am getting error

Error description: Unknown column 'بد' in 'field list'

and for echo of query I see

INSERT INTO pre (word, description, status) VALUES (بد, بدزبان بدگمان, active)

No sure what I am doing wrong?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Marksman
  • 59
  • 14

2 Answers2

1

Use single quotes instead of backticks in the values clause for strings:

$query = "INSERT INTO `pre` (`word`, `description`, `status`) VALUES ('$word', '$desc', '$status')";
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
potashin
  • 44,205
  • 11
  • 83
  • 107
1

You need to use single quotes for string input in your Statement as like:

$query = "
INSERT INTO pre (word, description, status) 
VALUES ('$word', '$desc', '$status')
";

Side note:
Make sure your table columns collation type is utf-8 because you are using other language (URDU) to insert.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
devpro
  • 16,184
  • 3
  • 27
  • 38