2013-06-11 3 views
-2

$i$q3 삭제 쿼리를 사용하도록 설정하면 다음 코드를 실행 한 후 에코하지 않습니다. 댓글을 달거나 $q3을 삭제하면 모든 문제가 해결됩니다.PHP 왜이 코드가 에코되지 않습니까?

어떻게 작동합니까? 당신의 SQL과 같은 경우에 거짓 mysqli_query 반환에 오류가 있기 때문에

$isfound = in_array("empty",$currentrooms0); 
if($isfound===true){ 
    for($i=0; $i<count($currentrooms0);$i++){ 
     if($currentrooms0[$i]=="empty"){ 
      $q3=mysqli_query($conn0,"delete from room_attributes where _current_created_rooms='empty' order by id desc limit 1")or die(mysqli_error($conn0));  
      echo $i-1; 
      break; 
     } 
    } 
+0

쿼리가 실패하고 오류가 출력되고 있습니까? 혹시? – Pudge601

+1

display_errors를 사용하도록 설정 했습니까? – Spudley

+1

코드에서'{'와'}'를 확인하십시오. –

답변

0

가 에코되지 않습니다 이유입니다. 당신이 다음 맨 위의 속성을 삭제 찾고있는이 SQL과 코드를 사용하여 고려할 수 있습니다 경우 직접 DELETE

에 속하는 WHERE 절 안에 ORDER BY를 사용할 수 없기 때문에

는 SQL은 오류가 발생합니다 작동해야합니다.

DELETE FROM room_attributes 
WHERE id IN (
    SELECT id FROM room_attributes 
    WHERE _current_created_rooms='empty' 
    ORDER BY id DESC 
    LIMIT 1 
) 
+0

여기에 대한 답변은 [code] $ isfound = in_array ("empty", $ currentrooms0); if ($ currentrooms0 [$ i] == "empty") { $ ($ i = 0; $ i $ i-1) {echo 0;} else {echo $ i-1;} 휴식; } } [/ code] – calmchess

0

나는

if($q3 ===TRUE){ 
    echo $i-1; 
    break; 
}else{ 
    echo "Connection Problem"; 
} 
+0

$ isfound = in_array ("empty", $ currentrooms0); if ($ currentrooms0 [$ i] == "empty") { $ ($ i = 0; $ i calmchess

-1

영업 쓴 .. 당신이 mysqli_connect에 문제를 다음과 같이 해보세요 있다고 생각 :

$isfound = in_array("empty",$currentrooms0); 
if($isfound===true){ 
    for($i=0; $i<count($currentrooms0);$i++){ 
     if($currentrooms0[$i]=="empty"){ 
      $q3=mysqli_query($conn0,"delete from room_attributes where _current_created_rooms='empty' order by id desc limit 1") or die(mysqli_error($conn0)); 
      if(i>$i-1) {echo 0;}else{echo $i-1;} 
      break; 
     } 
    } 
: 여기

이 답이다
+0

([답변으로 댓글을 달고 커뮤니티 위키로 변환] (http://meta.stackoverflow.com/questions/251597/question-with-no-answers-butissues-solved-in-the -코멘트).) –

관련 문제