2013-05-29 71 views
-3

線14
而($行= mysql_fetch_assoc($結果0))警告:mysql_fetch_assoc()預計參數1是資源,對象在C中給出: XAMPP htdocs中 FontLibrary 的index.php上線14

請幫忙。由於

下面是代碼

$HOST = 'localhost'; 
$USERNAME = 'root'; 
$PASSWORD = ''; 
$DB = 'Font Library'; 
$link = mysqli_connect($HOST, $USERNAME, $PASSWORD, $DB) or die(mysqli_connect_error()); 
if (!$link) { 
die(mysqli_error($link)); 
} 
$sql0="SELECT f.id, f.Font_Name, f.Font_Family 
     FROM font f 
     GROUP BY f.Font_Family 
     ASC"; 
$option = ''; 
$result0 = mysqli_query($link, $sql0) or die(mysqli_error($link)); 

while ($row = mysql_fetch_assoc($result0)) 
{ 
$option .= '<option value = " '.$row['f.id'].'">'.$row['f.Font_Family'].'</option>'; 
}  
+2

'集團BY' - >'ORDER BY' – BlitZ

+1

我認爲你應該使用mysql_fetch_assoc的mysqli_fetch_assoc ... –

回答

6

你混合mysql和mysqli的函數調用

變化

while ($row = mysql_fetch_assoc($result0)) 

while ($row = mysqli_fetch_assoc($result0)) 
1

=>。你不能使用GROUP BY ASC

所以更改

$sql0="SELECT f.id, f.Font_Name, f.Font_Family 
    FROM font f 
    GROUP BY f.Font_Family 
    ASC"; 

$sql0="SELECT f.id, f.Font_Name, f.Font_Family 
    FROM font f 
    GROUP BY f.Font_Family 
    "; 

$sql0="SELECT f.id, f.Font_Name, f.Font_Family 
    FROM font f 
    ORDER BY f.Font_Family 
    ASC"; 

=>。更改mysqlmysqli

while ($row = mysql_fetch_assoc($result0)) 

while ($row = mysqli_fetch_assoc($result0)) 
相關問題