이소스가 무슨 문제일까요

이소스가 무슨 문제일까요

QA

이소스가 무슨 문제일까요

답변 3

본문

  function checkip($item,$ip) {
              $q = mysqli_query($conn,"select * from post_likes where item_id = ".$item." and ip = '".$ip."' limit 1");
              return mysqli_num_rows($q);
            }
            checkip($row['no'],get_real_ip());

 

함수에 값들은 다 있는데요 근데 자꾸 에러뜨네요 ㅠㅠ 에코 찍어 봤는데 mysql은 아주 잘되는데 자꾸 에러가 문제네요 ㅠㅠ

 

select * from post_likes where item_id = 1 and ip = '218.239.29.216' limit 1
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/nescafe/public_html/public/post.php on line 93

이 질문에 댓글 쓰기 :

답변 3

function checkip ~~~~

   global $conn;

   $q = mysqli_query~~~~

이렇게 입력해 보세요.

위에 혹시라도 include한 파일이 있다면 위처럼 global $conn; 한 줄만 넣으시면 해결이 될 겁니다.

질문내용중 ip 는 삭제하심이...

답변 달린 글의 수정은 냑에서만 가능합니다.

mysqli_query("select * from post_likes where item_id = ".$item." and ip = '".$ip."' limit 1", $conn);

 

아닐가요?

 

혹은 $conn 이 없어도 괜찮을듯합니다.

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 76
© SIRSOFT
현재 페이지 제일 처음으로