我知道这种类型的问题之前问,但我想要的是计算从时间和时间的差异和时间。我是新手所以不能让自己在专家模式下我做了下面的代码,并在端面和错误,解决这个“可捕捉的致命错误:类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