-
[PHP] mysqli 의 쿼리 결과 다루기
mysqli 에서 SELECT 쿼리를 실행한 후, 그 결과값을 뽑아 내는 방법을 간단히 보겠습니다. $mysqli = new mysqli($DB[‘host’], $DB[‘id’], $DB[‘pw’], $DB[‘db’]); if (mysqli_connect_error()) { exit(‘Connect Error (‘ . mysqli_connect_errno() . ‘) ‘. mysqli_connect_error()); } $q = “SELECT * FROM ap_member WHERE id=’$user_id’”; $result = $mysqli->query( $q); 위처럼 루틴하게 mysqli 연결의 끈을 생성시키고, 쿼리를 실행시킵니다. 실행결과는 $result…
-
php에서 헥사코드 인코딩,디코딩하기
[php] //스트링을 헥사코드로 인코딩하기 function String2Hex($string){ $hex=”; for ($i=0; $i < strlen($string); $i++){ $hex .= dechex(ord($string[$i])); } return $hex; } [/php] [php] //헥사코드를 스트링으로 디코딩 하기 function Hex2String($hex){ $string=”;2014-07-08 for ($i=0; $i < strlen($hex)-1; $i+=2){ $string .= chr(hexdec($hex[$i].$hex[$i+1])); } return $string; } [/php]
-
php 를 이용하여 디렉토리에 있는 파일 검색하기
<? // target directory $directory=”./bgm”; // 저장된 디렉토리를 연다. “@”에러 생격도 출력 안하는데 @는 해결책이 아님 $handle = @opendir($directory); // 디렉토리가 존재하면(is_dir) if (is_dir($directory)) { while(false !== ($file = readdir($handle))) { /* 주의 ! readdir은 모든 디렉토리 안에 기본적으로 존재하는 “.”과 “..”또한 반환하는데 이를 조건을 추가하여 제거 해주면 된다.*/ if ($file != “.” && $file…
-
zipcode DB를 가져오는곳,.
-
session_start() 에러 해결방법
<?session_start();?>이렇게 달랑 하나 있는데 에러 메세지가 떴다. 에러 메세지는 다음과 같았다.Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at C:\APM_Setup6\htdocs\index.php:1) in C:\APM_Setup6\htdocs\ndex.php on line 1 구글 번역기를 돌려 보니 “세션 캐시를 보낼 수없습니다 리미 – 헤더를 이미 보낸”이라고 나왔다. 즉, 헤더를 이미 보냈기 때문에 세션을 시작할 수 없다는…
-
PHP 멀티파일 다운로드 하기