2011-05-08 3 views
1

가능한 중복 :
mysql_fetch_array() expects parameter 1 to be resource, boolean given in selectmysql 페치 배열 오류?

나는 :)이 일어나는 이유는 .. 도움 무슨 뜻인지 모르겠어요 내 스크립트에 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\FBlike\like.php on line 104 .. 는 무엇입니까? 오류에

$like_id=mysql_real_escape_string($_GET['id']); 

$sql=mysql_query("select * from likes WHERE id=$like_id DESC LIMIT 1"); 
while($row=mysql_fetch_array($sql)) 
{ 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

    <meta name="description" content="<?php print $row['like']; ?>"/> 

    <meta name="keywords" content="<?php print $row['like']; ?>" /> 

    <meta property="og:description" content="Click to See More..." /> 

     <meta property="fb:app_id" content="" /> 



    <meta property="og:title" content="<?php print $row['like']; ?>"/> 

    <meta property="og:type" content="activity"/> 

    <meta property="og:url" content="http://www.fbquote.me/like.php?id=<?php print $row['id']; ?>" /> 

    <meta property="og:site_name" content="pDank" /> 
<title><?php print $row['like']; ?></title> 

<?php } ?> 
+0

내가 마지막 mysql_error를()을 체크 할 것입니다 당신이는 mysql_fetch_array (를 호출하기 전에) – Scuzzy

답변

1

SQL 쿼리에 오류가 있습니다.

는()로 MYSQL_ASSOC 앞에 다음 코드를 추가하여 :

if (!$sql) { 
    die(mysql_error()); 
} 
2

mysql_query() 반환 FALSE, 당신은 쿼리에 오류가 ERGO.

mysql_error()을 사용하면 마지막 오류 메시지가 나타납니다. 쿼리를 의미 예

$result = mysql_query("select * from likes WHERE id=$like_id DESC LIMIT 1"); 
if (false === $result) { 
    throw new Exception('MySQL error: ' . mysql_error()); 
} 
0

를 들어

어떤 이유로 실패 (잘못된 구문, 열을 찾을 수 없습니다 ...) FALSE를 반환.

캡쳐하려면 $ sql (실제로 변수 $ result 또는 그 이름을 지정해야합니다. 일반적으로 쿼리 문자열에 $ sql이 사용됩니다)은 거짓이며, 그렇다면 print/log 함수 mysql_error()이 무엇이든 반환합니다.