Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "BartPeters";
- $password = "wachtw00rd";
- $database = "Gerrits";
- //create connection
- $conn = new mysqli($servername, $username, $password, $database);
- //check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $urlMachineON = 'http://192.168.0.150/awp/Shredder/PLCfiles/IOmachineActive.html';
- // get content
- $contentMachineON = file_get_contents($urlMachineON);
- //remove first 2 characters
- $truncate = substr($contentMachineON, 2);
- //remove last 5 characters
- $MachineOn = substr($truncate, 0, -5);
- $CurrentState = 2;
- if ($MachineOn != $CurrentState)
- {
- $stmt = $conn->prepare("INSERT INTO machineactiviteit (Time, MachineStatus) VALUES(NOW(), ?)");
- // De variablen die in de query gebruikt worden
- $stmt->bind_param('s', $MachineOn);
- if ($stmt->execute() === TRUE) {
- echo 'Gelukt';
- $CurrentState = $MachineOn;
- }
- else
- {
- echo $conn->error;
- }
- $stmt->close();
- }
- elseif($MachineOn == $currentState)
- {
- echo 'doe niets';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement