2014-04-09 47 views
-3

我花了數小時試圖遵循編碼器的所有偉大的建議,試圖解決這個問題。我知道這是50個其他帖子的副本,但無法找到足夠接近我的代碼來修復它。我是PHP新手,並且在無法更新的網站上有一箇舊的電子商務購物車。請不要因爲我的無知而激怒我。有人可以給我關於如何解決這個問題的確切說明。提前致謝!沒有足夠的智能來解決mysql_fetch_array()期望參數1

我剛剛直接從文件複製代碼。我沒有添加所有的@。

錯誤:

mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/xxx /public_html/vsadmin/inc/mod/text.php on line 18 

從test.php的

<?php 
    $cat = @$_GET['cat']; // Current Category ID 
    if(trim(@$_GET['cat'])!='') $theid = unstripslashes(@$_GET['cat']); 
    if(@$explicitid!='' && is_numeric(@$explicitid)) 
    [email protected]$explicitid; 
    elseif(@$usecategoryname && $theid!=''){ 
    $sSQL = 'SELECT sectionID FROM sections WHERE '.getlangid('sectionName',256)."='".escape_string($theid)."'"; 
    $result = mysql_query($sSQL) or print(mysql_error()); 
    if($rs=mysql_fetch_assoc($result)){ $catname=$theid; $theid=$rs['sectionID']; } 
    mysql_free_result($result); 
    } 
    $cat = $theid; 
    $queryrank="SELECT * from sections WHERE sectionID= '" . $cat . "' "; 
    $resultrank=mysql_query($queryrank); 
    ?> 
    <?php 
    while ($sSQL =mysql_fetch_array ($resultrank))//<< line 18 
    { 
    $text = $sSQL['cattext']; 
    $html = $sSQL['cathtml']; 
    $optiom = $sSQL['catoption']; 
    if($sSQL['catoption']==1) {print "$text ";} 
    else print "$html"; 
    } 
?> 
+0

你在哪裏添加了數據庫連接? – Jenz

+1

首先,停下所有'@'。你不想錯誤抑制!抑制錯誤正是使你無法弄清楚什麼是錯的! – deceze

+0

也是你的第18行.. – Jenz

回答

0

只有我在你的代碼中看到mysql_fetch_array的代碼是

while ($sSQL =mysql_fetch_array ($resultrank))

所以,$resultrank=mysql_query($queryrank);必然導致在false

Ergo,您的查詢$queryrank="SELECT * from sections WHERE sectionID= '" . $cat . "' "; 將引發錯誤。

echo the mysql_error and you know what's wrong。

而且,如果可以的話,使用mysql函數停止,它們被取消。改用mysqli或PDO。

+0

我無法爲所有者更新這個舊購物車。當我嘗試更新時,它會銷燬她的購物車。我向腳本添加了錯誤報告。我會看看會發生什麼。這是一個非常不活躍的購物車,因此可能需要時間。感謝您的幫助。 – user2992394

相關問題