我想製作一個系統,需要用戶默認時區,然後將其轉換爲服務器時區。這是用於任何用戶可以在我的網站上查看的IP日誌。我完全難倒...調用未定義的方法PDOStatement :: fetch_array()
<?php
$SQLGetIP = $odb -> prepare("SELECT * FROM `loginip` WHERE `username` = :username ORDER BY `loginip`.`date` DESC");
$SQLGetIP -> execute(array(':username' => $_SESSION['username']));
$getInfo = $SQLGetIP->fetch_array();
$query = $odb -> prepare("SELECT * FROM `users` WHERE `id` = :id");
$query -> execute(array(':id' => $_SESSION['id']));
$data = $query->fetch_array();
$dt1 = $getInfo['date'];
$tz = $data['timezone'];
$dt = new DateTime("@".$dt1."");
$dt -> setTimeZone(new DateTimeZone($tz));
$IP = $getInfo['logged'];
$Date = $dt->format('F d, Y - h:i:s A');
echo '<tr><td>'.$IP.'</td><td>'.$Date.'</td></tr>';
?>
你有兩個對fetch_array()的調用。哪一個是造成它的? – chanchal118 2014-09-27 06:47:48
爲什麼會發生該錯誤?它應該在用戶時區中顯示日期,但它不會。我的PHP錯誤日誌顯示[27-Sep-2014 06:31:03 UTC] PHP致命錯誤:調用未定義的方法PDOStatement :: fetch_array()在/home/public_html/iplogs.php在線84 – 2014-09-27 06:48:37
這條線是84這裏? – chanchal118 2014-09-27 06:50:48