-1
表結構:PHP - 調用一個成員函數FETCH_ASSOC()一個非對象
user table:
id:int
user:varchar
hash:varchar
realm:int
Game Table:
ID:int:auto
Game:varchar
Password:varchar
Difficulty:tinytext
Realm:tinytext
Empty:int
timestamp:int
Player Table:
ID:Int
GameID:INT
Name:varchar
timestamp:int
當我嘗試FETCH_ASSOC()我得到錯誤:
調用一個成員函數FETCH_ASSOC()非對象上
function RequestToRemove($Hash, $timestamp)
{
include "conf.php";
$conn = new mysqli($serverip, $username, $password, $dbname, $Port);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$hash = mysqli_escape_string($conn, $Hash);
$UserQuerry = "SELECT * from User where hash = '$hash'";
$UserResult = $conn->query($UserQuerry);
if (!$UserResult) {
echo "hash not found: ".$hash;
}
if ($UserResult->num_rows > 0)
{
while($UserRow = $resulti->fetch_assoc())
{
$PlayerQuerry = "SELECT * from Players where ID = '".$UserRow['id']."'";
$PlayerResult = $conn->query($PlayerQuerry);
while($PlayerRow = $PlayerResult->fetch_assoc())
{
$gameID = $PlayerRow['GameID'];
$gameQuerry = "SELECT * from games where ID = '$gameID'";
$gameResult = $conn->query($gameQuerry);
if ($gameResult->num_rows > 0)
{
while($GameRow = $gameResult->fetch_assoc())
{
if((int)$GameRow['timestamp'] <= ($timestamp - 30) && (int)$GameRow['Empty'] == 1)
{
$gameDeleteQuerry = "DELETE FROM games where id = '".$gameID."'";
$conn->query($gameDeleteQuerry);
echo "Game Updated";
}
}
$playerDeleteQuerry = "DELETE FROM Players where id = '$gameID'";
$gamesUpdateQuerry = "UPDATE games SET timestamp='$timestamp' where ID = '$gameID'";
$gamesUpdateResult = $conn->query($gamesUpdateQuerry);
if (!$gamesUpdateResult) {
echo "Can't UPDATE game! ID: $gameID Error: ". $conn->error;
return;
}
$conn->query($playerDeleteQuerry);
$PlayerQuerry = "SELECT * from players where GameID = '$gameID'";
$PlayerResult = $conn->query($PlayerQuerry);
if (!$PlayerResult) {
echo "Can't get players! Error: " . $conn->Error;
return;
}
if ($PlayerResult->num_rows <= 0) {
$gameUpdateEmptyQuerry = "UPDATE games SET Empty='1' where GameID = '".$gameID."'";
$conn->query($gameUpdateEmptyQuerry);
}
} else {
echo "0 results";
}
}
}
}
$conn->close();
}
但是當即時運行
SELECT * from User where hash = 'ae3cb232b5e489050bfed7ed984eb04c'
在HeidiSQL 我會得到一個排的反應,但我仍然不能FETCH_ASSOC()在PHP
爲編輯原因:顯示完整的功能,請
清楚,只是一個錯字我在這裏做^^ @弗雷德-II- – user3050767
固定錯字後,它'工作? – fsn
仍然沒有woking。 $ Hash =「ae3cb232b5e489050bfed7ed984eb04c」;它只是一個例子,它的會話散列 – user3050767