-1

For example I use

$building_name = $_POST['BuildingName'];
$metering_type = $_POST['MeteringType'];
$query = "INSERT INTO buildings (BuildingName, MeteringType)
                       VALUES ('$building_name', '$metering_type')";
if(mysqli_query($link, $query))
{
    echo json_encode(Array("success"=>true));
}

And I believe that this prevents me from SQL injections. Am I safe?

Dharman
  • 30,962
  • 25
  • 85
  • 135
ilhan
  • 8,700
  • 35
  • 117
  • 201

1 Answers1

6

No, that doesn't protect you in the slightest.

You need to use MySQLi's parameterized queries via prepare.

ceejayoz
  • 176,543
  • 40
  • 303
  • 368