-2

Parse error: syntax error, unexpected '"', '"' (T_CONSTANT_ENCAPSED_STRING)

I am trying to insert data from html form to database and I am getting an error

$sql="INSERT INTO shooting VALUES ('".$_POST["name"]"', '".$_POST["date"]"', '".$_POST["time"]"', '".$_POST["status"]')";
Nigel Ren
  • 56,122
  • 11
  • 43
  • 55
j.power
  • 21
  • 1
  • You are missing `.` dot 4 dot. – Niklesh Raut May 28 '18 at 17:29
  • **Danger**: You are **vulnerable to [SQL injection attacks](http://bobby-tables.com/)** that you need to [defend](http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php) yourself from. – Quentin May 28 '18 at 18:08

1 Answers1

-2

Hi there is issue in your syntax kindly check below.

 $sql="INSERT INTO shooting VALUES ('".$_POST["name"]."', '".$_POST["date"]."', '".$_POST["time"]."', '".$_POST["status"]."')";

And you should use mysql_real_escape_string method to prevent SQL injection.

$date = mysql_real_escape_string($_POST["date"]);

And insert $date variable in database.

Devraj verma
  • 407
  • 3
  • 14