I'm having trouble putting values on my php and sending them to My sql.
<?php
$tempSerialNumber = $_GET['sn'];
$tempLatitude = $_GET['l1'];
$tempLongitude = $_GET['l2'];
$servername = "localhost";
$username = "bornitex_uptoyou";
$password = "12345678";
$dbname = "bornitex_TMS";
$conn = new mysqli($servername, $username,$password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$val1 = $_GET['tempSerialNumber'];
$val2 = $_GET['tempLatitude'];
$val3 = $_GET['tempLongitude'];
$sql = "INSERT INTO LogGPS (SerialNumber, Latitude, Longitude)
VALUES ($val1,$val2,$val3)";
if ($conn->query($sql) === TRUE) {
echo "save OK";
} else {
echo "Error:" . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
The value I sent
http://uptoyoutest.bornitexpert.com/add02.php?sn=abc&l1=1.0&l2=2.0
error I got
Error:INSERT INTO LogGPS (SerialNumber, Latitude, Longitude) VALUES (,,)
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 ',)' at line 2
The database I created enter image description here