setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn1 = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); // set the PDO error mode to exception $conn1->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn2 = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); // set the PDO error mode to exception $conn2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Connection MySQL for imgs displaying. $bdd = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); } catch(Exception $e) { // Si il y a une erreur, arret du script. die('Erreur : '.$e->getMessage()); } $sql = "UPDATE `capteurs` SET `A/M` = '1' WHERE `capteurs`.`id` = 1"; // Prepare statement $stmt = $conn->prepare($sql); // execute the query $stmt->execute(); $conn = null; //Simulation of Arduino sensors reception $randl = rand(0, 9999); $randw = rand(0, 50); //send generated numbers to database $sql1 = "UPDATE `capteurs` SET `lux` = '$randl' WHERE `capteurs`.`id` = 1"; $stmt = $conn1->prepare($sql1); $stmt->execute(); $sql2 = "UPDATE `capteurs` SET `vent` = '$randw' WHERE `capteurs`.`id` = 1"; $stmt2 = $conn2->prepare($sql2); $stmt2->execute(); ?>