PHP mysqli_connect 접속테스트 표준구문
페이지 정보
본문
<?php
$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db");
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
mysqli_close($link);
//phpinfo();
?>
정상 접속
Success: A proper connection to MySQL was made! The my_db database is great. Host information: Localhost via UNIX socket
접속 오류.1
Warning: mysqli_connect(): (HY000/2002): No such file or directory in /home/happyjung/www/test.php on line 2
Error: Unable to connect to MySQL. Debugging errno: 2002 Debugging error: No such file or directory
접속 오류.2
Error: Unable to connect to MySQL. Debugging errno: 2002 Debugging error: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
관련자료
https://secure.php.net/manual/kr/function.mysqli-connect.php
https://www.php.net/manual/en/function.mysqli-connect.php
$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db");
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
mysqli_close($link);
//phpinfo();
?>
정상 접속
Success: A proper connection to MySQL was made! The my_db database is great. Host information: Localhost via UNIX socket
접속 오류.1
Warning: mysqli_connect(): (HY000/2002): No such file or directory in /home/happyjung/www/test.php on line 2
Error: Unable to connect to MySQL. Debugging errno: 2002 Debugging error: No such file or directory
접속 오류.2
Error: Unable to connect to MySQL. Debugging errno: 2002 Debugging error: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
관련자료
https://www.php.net/manual/en/function.mysqli-connect.php
댓글목록
등록된 댓글이 없습니다.