2013-09-24 62 views
0

這是我的錯誤:錯誤 「警告:mysql_result()[function.mysql-結果]:無法跳轉到行0」

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 53 in C:\xampp\htdocs\includes\class.rooms.php on line 35

這是在編碼的行:

return mysql_result(
     dbquery(
      "SELECT " . $var . " FROM rooms WHERE id = '" . $roomId . "' LIMIT 1" 
     ), 0); 
+5

如果你在遊戲早期,你可能想從mysql函數切換到mysqli或pdo。 (舊)mysql函數已被棄用,不再被php支持。 mysqli和pdo是更好的選擇。 – shmuli

+0

可能查詢失敗,請執行var_dump。 – Mihai

+0

請使用比「我的代碼有錯誤」更具體的標題;如果每個人都使用這樣的標題,那麼這裏的問題索引將是無用的';-)'。謝謝。 – halfer

回答

0

首先,我不熟悉函數dbquery。我知道mysql_query,但也許這是你自己的方法。問題在於,很可能您的查詢沒有返回任何行。 嘗試調試與

$result = ..query.. 
if (!mysql_num_rows($result)) 
    echo "No rows."; 
1

假設$ var和$ roomId無誤也許他有用的測試代碼排除,這似乎是一個用戶定義的DBQuery功能功能

$query_temp = "SELECT " .$var ." FROM rooms WHERE id = '" .$roomId ."' LIMIT 1"; 

/* 
* This is for test purpose and in production you would not want to display neither the query nor error to the user. 
*/ 

$result_temp = mysql_query($query_temp) or die ("Error in query: $query_temp. " .mysql_error()); 

// var_dump(mysql_fetch_array ($result_temp)); 

return($result_temp); 

As already commented by shmuli it is worth to switch to mysqli or pdo in the beginning itself

+0

你先生是一個genuis,這解決了我的問題! –

+0

_As我的回答解決了您的問題,您可能需要考慮接受它,因爲它可能也會幫助其他人解決這個問題。謝謝_ **。 。 ** – Uours

相關問題