- <?php
- $mysql_con = mysql_connect("localhost", "test1", "test1")
- or die('Could not connect: ' . mysql_error());
- if($mysql_con) echo "연결 성공";
- // 연결 성공
- /*연결 실패시 Warning메세지와 함께 die()함수와 mysql_error()함수 출력
- Could not connect:
- mysql_error()함수에 의해 실패 원인 출력
- */
- ?>
--------------------------------------------------------------------------------------------
string mysql_error ([ resource $link_identifier = NULL ] )
3. 라인
mysql 서버 연결 실패시 실패 원인을 출력합니다.
비슷한 함수로는 mysql_errno()함수가 있습니다.(에러번호출력)
'php5 > mysql관련함수' 카테고리의 다른 글
mysql character set 반환 - string mysql_client_encoding () (0) | 2014.01.13 |
---|---|
mysql 데이터베이스 선택 - bool mysql_select_db ( string $database_name ) (0) | 2014.01.13 |
mysql query 실행 (DB 생성, 삭제) - resource mysql_query ( string $query ), mysql_create_db(), mysql_drop_db() (0) | 2014.01.13 |
mysql 연결 종료 - bool mysql_close () (0) | 2014.01.13 |
mysql 연결 - resource mysql_connect () (0) | 2014.01.13 |