-3

syntax error, unexpected '$Name' (T_VARIABLE) error appears for this line

My query is-

$sql = "INSERT INTO person (Name,Email) VALUES ("$Name","$Email")";
shubham715
  • 3,324
  • 1
  • 17
  • 27
Wenuka
  • 1
  • 1
  • 2

2 Answers2

1

Use single quote in value

$sql = "INSERT INTO person (Name,Email) VALUES ("$Name","$Email")";

To

$sql = "INSERT INTO person (Name,Email) VALUES ('$Name','$Email')";
Devsi Odedra
  • 5,244
  • 1
  • 23
  • 37
0

You cannot use quote chars like that, the second one would terminate the string you define. Instead try using different types of quotes. That allows to actually have a quote character inside your defined string.

Take a look at this modified and working version:

$sql = "INSERT INTO person (Name, Email) VALUES ('$Name', '$Email')";

Be aware however that such creation of a sql statement smells very much of sql injection attack vulnerability...

arkascha
  • 41,620
  • 7
  • 58
  • 90