PHP ¼Ò½º °ü·Ã

   Á¶È¸ 3051   Ãßõ 0    

Notice: Undefined index: temperature in C:\xampp\htdocs\1\dht.php on line 20 

웹에서 뜨는 텍스트이고 아래는 해당  PHP 소스코드입니다.

20번째 라인이 밑줄과 굵게 표시된 구문입니다.

뭐가 문제일까요?


 


class dht11{

 public $link='';

 function __construct($temperature, $humidity){

  $this->connect();

  $this->storeInDB($temperature, $humidity);

 }

 

 function connect(){

  $this->link = mysqli_connect('localhost','root','') or die('Cannot connect to the DB');

  mysqli_select_db($this->link,'') or die('Cannot select the DB');

 }

 

 function storeInDB($temperature, $humidity){

  $query = "insert into set humidity='".$humidity."', temperature='".$temperature."'";

  $result = mysqli_query($this->link,$query) or die('Errant query:  '.$query);

 }

 

}

{if($_GET['temperature'] != '' and  $_GET['humidity'] != '')

 $dht11=new dht11($_GET['temperature'],$_GET['humidity']);

}

?>

ªÀº±Û Àϼö·Ï ½ÅÁßÇÏ°Ô.
isset À» »ç¿ëÇغ¸¼¼¿ä ^^
¾Æ´Ï¸é index ƒ”ÀÌ ¾øÀ»¶§ ±âº»°ªÀ» ÁöÁ¤ÇϽðųª..
¾Æ´Ï¸é get ÆĶó¹ÌÅ͸¦ ³Ñ±â°Å³ª

ÇöÀç ¹®Á¦´Â get °ªÀÌ ¾ø´Â°Å °°½À´Ï´Ù.
     
ÀÌÈñÁÖ 2019-11
PHP¸¦ Çϳªµµ ¸ô¶ó¼­ ¹«½¼ ¸»¾¸À» ÇϽô°ÇÁö Àß ¸ð¸£°Ú½À´Ï´Ù..¤¾¤¾

Çش籸¹®Àº ¾î¼´Ù ¿À·ù¸¦ ¹ß°ßÇؼ­ ¼öÁ¤Çߴµ¥ ¼Ò½ºÄÚµå´ë·Î SQL¿¡¼­ °ªÀ» ÀÐÀ» ¼ö°¡ ¾ø´Â°Éº¸´Ï ´Ù¸¥ ¾îµð¿£¼±°¡ ¹®Á¦°¡ ÀִµíÇØ¿ä
MC¾µ 2019-11
if($_GET['temperature'] != '' and  $_GET['humidity'] != ''){
     
ÀÌÈñÁÖ 2019-11
³× Çش籸¹®À» ¼öÁ¤ÇÏ°í À¥ÂÊ¿¡¼­´Â ¹®Á¦°¡ ¹ß»ýÇÏÁö ¾ÊÁö¸¸ SQL¿¡¼­ DB¸¦ »õ·Î°íħÇصµ ¿øÇÏ´Â µ¥ÀÌÅÍ°ªÀÌ µé¾î¿ÀÁö ¾Ê¾Æ¼­

¾Æ¿¹ °¥¾Æ ¾þ¾ú½À´Ï´Ù..
Notice ´Â ¿À·ù°¡ ¾Æ´ÏÁö¸¸, º¯¼ö Á¤ÀÇ°¡ ¾ÈµÇ¾ú´Âµ¥ »ç¿ëÇÏ·Á°í ÇÒ¶§ µîÀÇ °æ¿ì¿¡µµ ¸Þ½ÃÁö¸¦ Ãâ·ÂÇؼ­ ¸ÂÃç¼­ ó¸®ÇϽǷÁ¸é º¯¼ö Á¸ÀçÀ¯¹«¸¦ È®ÀÎÇÏ°í °ªÀ» ºñ±³ÇÏ¿© »ç¿ëÇØ¾ß ÇÕ´Ï´Ù. º¸Åë notice ´Â ¸Þ½ÃÁö¸¦ ²ô°í »ç¿ëÀ» ÇÏ°í¿ä. ¾Æ·¡ ¹æ¹ýÀ» »ç¿ëÇÏ½Ã¸é µË´Ï´Ù.

php.ini ¿¡¼­ error_reporting Ç׸ñÀ» ã¾Æ ~E_NOTICE Ç׸ñÀ» Ãß°¡ÇØÁÝ´Ï´Ù.
¿¹) error_reporting = E_ALL & ~E_NOTICE

¶Ç´Â °øÅëinclude µÇ´Â ÆÄÀÏ Ã¹¸Ó¸®¿¡ ¾Æ·¡ ±¸¹®À» ½áÁÝ´Ï´Ù.

error_reporting(E_ALL & ~E_NOTICE);
ini_set("display_errors", 1); //1Àº È­¸é¿¡ ¿¡·¯Ç¥½Ã, 0Àº ¿¡·¯Ç¥½Ã ¾ÈÇÔ
     
ÀÌÈñÁÖ 2019-11
¤¾¤¾°¨»çÇÕ´Ï´Ù.

ÇØ°áÇß½À´Ï´Ù. ÇÁ·Î±×·¡¹ÖÂÊÀ» Á¤¸» Çϳªµµ ¸ô¶ó¼­ ±¸±Û¸µÇØ°¡¸ç ÁÖ¸Ô±¸±¸½ÄÀ¸·Î ã¾Æ°¡´Â ÁßÀε¥ Á¤¸» ½±Áö¾Ê³×¿ä~

ÀÌÁ¦ ¾ÆµÎÀÌ³ë »ó¿¡¼­ C¾ð¾î ±â¹ÝÀÇ µÎ ¼Ò½º¸¦ ÇÕÃÄ¾ß Çϴµ¥ ¾îµð¼­ ÇÕÃÄ¾ß Çϴ°ÇÁö ¸·¸·ÇÕ´Ï´Ù..¤»¤»


QnA
Á¦¸ñPage 1071/5677
2014-05   4937010   Á¤ÀºÁØ1
2015-12   1473970   ¹é¸Þ°¡
2020-02   2138   osthek83
2020-02   4688   Ç®·Îµå½Ã½ºÅÛ
2020-02   2959   ¹ÙºÎÆÃÀÌ
2020-02   2393   ¹Ì¼ö¸Ç
2020-02   2386   ´ëÀü±è´ë¸®
2020-02   2480   ÇູÇϼ¼
2020-02   2563   °Ü¿ï³ª¹«
2020-02   2333   ºí·ç¿µ»ó
2020-02   2857   ±ô¹Ú±ô¹Ú°¡
2020-02   2955   Ä«¸Ó
2020-02   2721   Æ۽̱Û
2020-02   2676   ¿Ã»©¹ÌÀá¿Í
2020-02   2530   ¸»ÄÃ
2020-02   2106   ÇÏ´ÃÇÏ´Ã
2020-02   7431   º´¸ÀÆù
2020-02   5255   ghostman
2020-02   4438   °ËÀºÄá
2020-02   2260   À¯È£ÁØ
2020-02   4159   º´¸ÀÆù
2020-02   2380   HATBAN