I want is to calculate the time difference from to times intime and outtime. I did the below code and at the end face an error
Catchable fatal error: Object of class mysqli_result could not be converted to string in C:\wamp\www\testsite\time_test.php on line 105
<?php
$con = mysqli_connect("localhost","root","","testsite") OR die("Could not connect: ".mysqli_error());
if (isset($_POST['isubmit'])) {
// Check the cookie exits or not
if (isset($_COOKIE['uid'])) {
$_COOKIE['uid'];
}
$uid = $_COOKIE['uid'];
echo "Hello user: ".$uid;
$isql = mysqli_query($con, "INSERT INTO `time`(`uid`, `intime`, `date`) VALUES ('$uid',CURTIME(),CURDATE())");
$lid = mysqli_insert_id($con);
echo $lid;
}
if (isset($_POST['osubmit'])) {
if(isset($_COOKIE['uid'])) {
$_COOKIE['uid'];
}
$uid = $_COOKIE['uid'];
$ssql= mysqli_query($con,"SELECT `intime`, `outtime`, `date` FROM `time` WHERE `uid`=".$uid);
while ($row = mysqli_fetch_array($ssql)) {
$intime = $row['intime'];
$outtime= $row['outtime'];
$date = $row['date'];
if(!empty($date)){
$tmp = mysqli_query($con, "SELECT CURTIME()");
$lid = mysqli_insert_id($con);
$temp= strtotime($outtime) - strtotime($intime);
echo $temp;
//below line is line number 105
$usql= "UPDATE `time` SET `outtime`= $tmp,`diff`= '$temp' WHERE `id`=".$lid." AND `uid`=".$uid;
$run = mysqli_query($con, $usql);
if (!$run) {
die("Update database query error: ". mysqli_error());
}
}
}
}
?>