0

I know there must be some sort of error here but I cannot find it at all. If someone could please have a look at my code with fresh eyes maybe I am missing something

This is my code to insert into DB

// Create connection
$conn = new mysqli($host, $username, $password, $db_name);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$sql = "INSERT INTO panic (Name, msisdn, lat, long)
VALUES ('$slname', '$slcustom1', '$lat', '$long')";

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();

This is my error:

Error: INSERT INTO panic (Name, msisdn, lat, long) VALUES ('eTrack Demo', '0839008225', '-26.253604199999998', '28.2023469') You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'long) VALUES ('eTrack Demo', '0839008225', '-26.253604199999998', '28.2023469')' at line 1

It is drawing all the correct values but still gives the error.

All the tables are named correctly and all are INT type

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
James Wright
  • 143
  • 10

0 Answers0