$devicename ); $deviceCheck_stmt = $conn->prepare($deviceCheck_sql); $deviceCheck_stmt->execute($deviceCheck_qryparams); //$row = $deviceCheck_stmt->setFetchMode(PDO::FETCH_ASSOC); $deviceCount = $deviceCheck_stmt->rowCount(); if ($deviceCount > 0) { //device exists in database //update device states/status/sensor value $logEntry_sql = "UPDATE $tablename SET time_stamp=:time_stamp, value1=:value1, ip_address=:ip_address WHERE device_name=:device_name"; } else { //device does nto exist in database //insert device state/status/sensor value $logEntry_sql = "INSERT INTO $tablename (time_stamp, device_name, value1, ip_address) VALUES(:time_stamp, :device_name, :value1, :ip_address)"; } $logEntry_qryparams = array( ':time_stamp' => $timestamp, ':device_name' => $devicename, ':value1' => $value1, ':ip_address' => $userip ); $logEntry_qry = $conn->prepare($logEntry_sql); $results = $logEntry_qry->execute($logEntry_qryparams); //send a response back to Arduino if desired if($results){ //send update message back to arduino to set led or whatever displaying the entry was successful echo "success";//whatever message/format you want }else{ //send update message back to arduino to set led or whatever displaying the entry was successful echo "fail";//whatever message/format you want //db post/insert (log entry) failed. //echo "

The log entry failed.

" . var_dump($logEntry_qry ->errorInfo()); } } ?>