I am sending values to a php script on the same server as a MySQL database. A php script sends the values to the database. However, somewhere along the path sometimes a value loses a decimal and I end up with an extremely high value.
I am monitoring PH and a few other things so the number is relatively low (between 4-12). Sometimes I end up with 720 instead of 7.20. Should this be corrected through a trigger? If so how? Or should it be handled on the PHP side? How can I not accept values or render them null when entering? Thank you for your time.
<!DOCTYPE html>
<html>
<body>
<h1></h1>
<?php
// Create connection
$con = mysqli_connect("localhost", "***", "***", "***");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$temp1 = ( $_GET["1"] * 9/5)+32;
$temp2 = ( $_GET["3"] * 9/5)+32;
if ($_SERVER["REQUEST_METHOD"] == "GET") {
$sql = "INSERT INTO `ANALOG_SENSORS` (`TEMPERATURE`, `HUMIDITY`, `TEMPERATURE2`, `HUMIDITY2`,`PH`,`DATE_TIME`)
VALUES (" . $temp1 . ", " . $_GET["2"] . ", " . $temp2 . ", " . $_GET["4"] . ", " . $_GET["5"] . ",
NOW()- INTERVAL 7 HOUR)";
$result = mysqli_query($con, $sql);
}
</body>
</html>