2014-02-20 56 views
0

修復了我的主MySQL錯誤之後,我現在發現包含我創建的MySQL表的網站上的PHP存在問題。我收到的文字:涉及MySQL的Web(PHP)錯誤

Website link directly to error

警告:mysql_fetch_array()預計參數1是資源,布爾在在線/home/content/26/10406626/html/highscore/index.php給出258

這是我$結果文件中:

if ($skill == "Attack" || $skill == "Defence" || $skill == "Strength" || $skill == "Hitpoints" || $skill == "Range" || $skill == "Prayer" || $skill == "Magic" || $skill == "Cooking" || $skill == "Woodcutting" || $skill == "Fletching" || $skill == "Fishing" || $skill == "Firemaking" || $skill == "Crafting" || $skill == "Smithing" || $skill == "Mining" || $skill == "Herblore" || $skill == "Agility" || $skill == "Thieving" || $skill == "Slayer" || $skill == "Farming" || $skill == "Runecraft" || $skill == "Hunter" || $skill == "Construction" || $skill == "Summoning" || $skill == "Dungeoneering") { 
    mysql_select_db("scores", $con); 
    $result = mysql_query("SELECT * FROM skills WHERE ". $PLAYERS_TO_NOT_SHOW . " ORDER BY " . $skill . "lvl DESC, " . $skill . "xp DESC"); 
    } 

else { 
    $skill = ""; 
    mysql_select_db("scores", $con); 
    $result = mysql_query("SELECT * FROM skillsoverall WHERE ". $PLAYERS_TO_NOT_SHOW . " ORDER BY lvl DESC, xp DESC"); 
    } 

釷是爲線254至278: 顯然,線258是*而($行= mysql_fetch_array($結果))*

<?php 

$rank = 1; 

while($row = mysql_fetch_array($result)) 
    { 
    echo "<a name=\"" . $rank . "\"></a>"; 
    echo "<a class=\"row\">"; 
    echo "<span class=\"columnRank\">"; 
    echo "<span>" . $rank . "</span>"; 
    echo "</span>"; 
    echo "<span class=\"columnName\">"; 
    echo "<span>" . $row['playerName'] . "</span>"; 
    echo "</span>"; 
    echo "<span class=\"columnLevel\">"; 
    echo "<span>" . $row[$skill . 'lvl'] . "</span>"; 
    echo "</span>"; 
    echo "<span class=\"columnXp\">"; 
    echo "<span>" . $row[$skill . 'xp'] . "</span>"; 
    echo "</span>"; 
    echo "</a>"; 
    $rank++; 
    } 
mysql_close($con); 
?> 
+0

你能還供應其中'$ result'設置的線路? – EWit

+0

@EWit是的,我只是做到了。抱歉! – user2619426

+0

什麼是$ PLAYERS_TO_NOT_SHOW?我認爲這是你的問題來自 – CodeBird

回答

0

您的查詢失敗,因此不會產生查詢的資源,而是生產假。

透露自己的動態生成的查詢是什麼樣子,揭示錯誤,試試這個:

$result2 = mysql_query($result) or die($result."<br/><br/>".mysql_error()); 
0

你的問題躺在這兒:

$result = mysql_query("SELECT * FROM skills WHERE ". $PLAYERS_TO_NOT_SHOW . " ORDER BY " . $skill . "lvl DESC, " . $skill . "xp DESC"); 

怎麼一回事,因爲的mysql_query函數返回布爾值,我suposse是假的。從php.net手冊 http://pl1.php.net/mysql_query的mysql_query函數返回:

For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning 
resultset, mysql_query() returns a **resource** on success, or FALSE on error. 

For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, 
mysql_query() returns TRUE on success or FALSE on error.