Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $json = file_get_contents('php://input');
- echo $json;
- $data = json_decode($json);
- $ctlr_id = $data->ctlr_id;
- $auth = $data->auth;
- $kwh_id = $data->kwh_id;
- $kwh_type =$data->kwh_type;
- $type_kwh_code = $data->type_kwh_code;
- $va = (float)$data->va;
- $vb = (float)$data->vb;
- $vc = (float)$data->vc;
- $ia = (float)$data->ia;
- $ib = (float)$data->ib;
- $ic = (float)$data->ic;
- $pf = (float)$data->pf;
- $f = (float)$data->f;
- $kwh = (float)$data->kwh;
- $_ts = $data->ts;
- $time = strtotime($_ts);
- $ts = date("Y-m-d H:i:s", $time);
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbName = "pantaukwh";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbName);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $sql = "INSERT INTO pm05 (ctlr_id, auth, kwh_id, kwh_type, type_kwh_code, va, vb, vc, ia, ib, ic, pf, f, kwh, ts)
- VALUES ('$ctlr_id', '$auth', '$kwh_id', '$kwh_type', '$type_kwh_code', '$va', '$vb', '$vc', '$ia', '$ib', '$ic', '$pf', '$f', '$kwh', '$ts')";
- if (mysqli_query($conn, $sql)) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . mysqli_error($conn);
- }
- mysqli_close($conn);
- ?>
Add Comment
Please, Sign In to add comment