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']);
}
?>
¾Æ´Ï¸é index ƒ”ÀÌ ¾øÀ»¶§ ±âº»°ªÀ» ÁöÁ¤ÇϽðųª..
¾Æ´Ï¸é get ÆĶó¹ÌÅ͸¦ ³Ñ±â°Å³ª
ÇöÀç ¹®Á¦´Â get °ªÀÌ ¾ø´Â°Å °°½À´Ï´Ù.
Çش籸¹®Àº ¾î¼´Ù ¿À·ù¸¦ ¹ß°ßÇؼ ¼öÁ¤Çߴµ¥ ¼Ò½ºÄÚµå´ë·Î SQL¿¡¼ °ªÀ» ÀÐÀ» ¼ö°¡ ¾ø´Â°Éº¸´Ï ´Ù¸¥ ¾îµð¿£¼±°¡ ¹®Á¦°¡ ÀִµíÇØ¿ä
¾Æ¿¹ °¥¾Æ ¾þ¾ú½À´Ï´Ù..
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Àº ¿¡·¯Ç¥½Ã ¾ÈÇÔ
ÇØ°áÇß½À´Ï´Ù. ÇÁ·Î±×·¡¹ÖÂÊÀ» Á¤¸» Çϳªµµ ¸ô¶ó¼ ±¸±Û¸µÇØ°¡¸ç ÁÖ¸Ô±¸±¸½ÄÀ¸·Î ã¾Æ°¡´Â ÁßÀε¥ Á¤¸» ½±Áö¾Ê³×¿ä~
ÀÌÁ¦ ¾ÆµÎÀÌ³ë »ó¿¡¼ C¾ð¾î ±â¹ÝÀÇ µÎ ¼Ò½º¸¦ ÇÕÃÄ¾ß Çϴµ¥ ¾îµð¼ ÇÕÃÄ¾ß Çϴ°ÇÁö ¸·¸·ÇÕ´Ï´Ù..¤»¤»