我知道這種類型的問題之前問,但我想要的是計算從時間和時間的差異和時間。我是新手所以不能讓自己在專家模式下我做了下面的代碼,並在端面和錯誤,解決這個「可捕捉的致命錯誤:類mysqli_result的對象不能轉換爲C:\ wamp \ www \測試網站\ time_test.php在線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());
}
}
}
}
?>
'$ TMP = mysqli_query($ CON 「選擇CURTIME()」);'可能是一個有點過度殺死你不覺得?除非你的mysql服務器與你的apache服務器不同,並且在另一個GMT – Brewal 2014-12-03 09:13:39
下運行,否則我總是首先在本地驅動器上執行操作,而不是上傳它並更改我在日記中指出的必要事項。通過這個,我可以從我的電腦中獲得時間,這個時間很好。我只是想擺脫錯誤... – 2014-12-03 09:16:54